Created
August 9, 2020 23:09
-
-
Save beyondxscratch/13a481b9c409ace653d8bed7a19c7c2d to your computer and use it in GitHub Desktop.
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