Is there any possibility implement interface in annotation? Something like:
public @interface NotNull implements LevelInterface { ValidationLevel level(); };
Annotation types are a form of interface, which will be covered in a later lesson. For the moment, you do not need to understand interfaces. The body of the previous annotation definition contains annotation type element declarations, which look a lot like methods. Note that they can define optional default values.
@FunctionalInterface annotation is used to ensure that the functional interface can't have more than one abstract method.
Java annotations are metadata (data about data) for our program source code. They provide additional information about the program to the compiler but are not part of the program itself. These annotations do not affect the execution of the compiled program.
The only way to look for ALL implementations which hold the specific interface is to call on Person i.e. Person. class. getAnnotations() . This unfortunately only yields the annotations which are declared on the Person interface.
No, the compiler says:
Annotation type declaration cannot have explicit superinterfaces
You cannot extend either:
Annotation type declaration cannot have an explicit superclass
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