Skip to content

Instantly share code, notes, and snippets.

@beyondxscratch
Created August 9, 2020 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beyondxscratch/13a481b9c409ace653d8bed7a19c7c2d to your computer and use it in GitHub Desktop.
Save beyondxscratch/13a481b9c409ace653d8bed7a19c7c2d to your computer and use it in GitHub Desktop.
@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