Skip to content

Instantly share code, notes, and snippets.

@beyondxscratch
Created August 9, 2020 23:09
Embed
What would you like to do?
@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