This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Aggregate | |
class Recommendation(val id: UUID = UUID.randomUUID(), val criteria: Criteria, talks: Set<Talk>) { | |
val talks: Set<Talk> | |
init { | |
checkCriteriaTalkFormatsCorrespondToTheTalksOne(talks) | |
this.talks = talks.toSet() | |
} | |
private fun checkCriteriaTalkFormatsCorrespondToTheTalksOne(talks: Set<Talk>) { | |
if (talks.any { !criteria.hasTalkFormat(it.format) }) { | |
throw IllegalArgumentException("Criteria talk formats doesn't correspond to the format of the recommended talks") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment