3

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?

Community
  • 1
  • 1
  • 4
    Are you interested in interfaces or in annotations? You words say one, your code says another.. – voddan Jan 03 '17 at 07:48

2 Answers2

4

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.

yole
  • 92,896
  • 20
  • 260
  • 197
0

From https://kotlinlang.org/docs/reference/nested-classes.html

interface OuterInterface {
    class InnerClass
    interface InnerInterface
}

class OuterClass {
    class InnerClass
    interface InnerInterface
}
Noah
  • 2,718
  • 3
  • 17
  • 23