Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested interface in Kotlin

Tags:

kotlin

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?

like image 881
Oliver Wahlen Avatar asked Sep 03 '26 20:09

Oliver Wahlen


1 Answers

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.

like image 99
yole Avatar answered Sep 08 '26 14:09

yole