Jaro
05/11/2020, 10:02 AMopen class A(val strings: List<String>)
class B(strings: List<String>) : A(strings)
class C(strings: List<String>) : A(strings)
these classes are used in my REST API and I would like to validate their content with JSR annotations. I want to check that the collection strings
in class B
is not empty using @NotEmpty
but I can apply this validation only on the property declaration (if I’m not mistaken). What is the best Kotlin way to add this validation to class B
? In java I would probably override getter in class B and add annotation there, can I do something similar in Kotlin?Jukka Siivonen
05/11/2020, 10:12 AMJaro
05/11/2020, 10:19 AMthanksforallthefish
05/11/2020, 11:30 AMclass B(strings: List<String>) : A(strings)
to class B(@get:NotEmpty override val strings: List<String>) : A(strings)
open class A(open val strings: List<String>)
Jaro
05/11/2020, 11:47 AMahmad
05/12/2020, 10:41 AMJukka Siivonen
05/12/2020, 10:43 AMahmad
05/12/2020, 12:22 PMthanksforallthefish
05/12/2020, 12:30 PM