Is it possible to have an custom annotation that do the same work as another annotation ?
For example if I write @MyCustomAnnotation like I have write @override !
It is also possible to use multiple annotations on the same declaration: @Author(name = "Jane Doe") @EBook class MyClass { ... } If the annotations have the same type, then this is called a repeating annotation: @Author(name = "Jane Doe") @Author(name = "John Smith") class MyClass { ... }
You can repeat an annotation anywhere that you would use a standard annotation.
If an @Target meta-annotation is present, the compiler will enforce the usage restrictions indicated by ElementType enum constants, in line with JLS 9.7. 4. For example, this @Target meta-annotation indicates that the declared type is itself a meta-annotation type.
The @interface element is used to declare an annotation. For example: @interface MyAnnotation{}
There's definitely no support for inheritance with Annotations. See: Is there something like Annotation Inheritance in java?
So without that, unless some framework chose to provide extensibility around its annotation processing, you would have a lot of trouble achieving such an effect.
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