Is it possible to specify default value for annotation field of another annotation type?
-
23-04-2021 - |
Pregunta
public @interface InnerAnnotation {
String value() default "hello";
}
public @interface OuterAnnotation {
InnerAnnotation value() default ???
}
And one more case:
public @interface AnotherOuterAnnotation {
InnerAnnotation[] value() default ??? UPD: {}
}
Solución
Yes, its possible:
public @interface InnerAnnotation {
String value() default "hello";
}
public @interface OuterAnnotation {
InnerAnnotation value() default @InnerAnnotation(value = "Goodbye");
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow