In Java it is possible to declare interfaces inside of interfaces:
....
public @interface NotEmpty {
....
public @interface List {
NotEmpty[] value();
}
}
The example is taken from hibernate's NotEmpty validator. Please see the following discussion for what this is good for.
Unfortunately in Kotlin an annotation class must not have a body.
How can nested interfaces be achieved in Kotlin?
There is no support for nested annotation classes in Kotlin 1.0, and no plans to add that support in version 1.1. It's possible that the feature will be supported in later versions. In the mean time, you can declare your nested annotation classes in Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With