Skip to content

Instantly share code, notes, and snippets.

@macieknajbar
Last active July 8, 2020 07:23
Show Gist options
  • Save macieknajbar/2a63e6cccb7af5ec1f3a549cb0c2be21 to your computer and use it in GitHub Desktop.
Save macieknajbar/2a63e6cccb7af5ec1f3a549cb0c2be21 to your computer and use it in GitHub Desktop.
enum class Assessment {
A, B, C, D, E, F
}
data class CandidateEntity(val id: String, val fullName: String, val contactNumbers: Collection<PhoneNumberEntity> = mutableListOf(), val grade: Assessment?) {
init {
if (fullName.split(' ').size < 2) throw NotFullNameException()
}
fun addContactNumber(contactNumber: PhoneNumberEntity) {
(contactNumbers as MutableCollection).add(contactNumber)
}
}
data class PhoneNumberEntity(val phoneNumber: String) {
init {
if (phoneNumber.matches(Regex("^\\+\\d{11}\$")).not())
throw IncorrectPhoneNumberException()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment