Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to specify default value for annotation field of another annotation type?

public @interface InnerAnnotation {
    String value() default "hello";
}

public @interface OuterAnnotation {
    InnerAnnotation value() default ???
}

And one more case:

public @interface AnotherOuterAnnotation {
    InnerAnnotation[] value() default ??? UPD: {} 
}
like image 853
Roman Avatar asked Feb 05 '12 21:02

Roman


1 Answers

Yes, its possible:

public @interface InnerAnnotation {
    String value() default "hello";
}

public @interface OuterAnnotation {
    InnerAnnotation value() default @InnerAnnotation(value = "Goodbye");
}
like image 195
Perception Avatar answered Oct 06 '22 15:10

Perception