Java Reference
In-Depth Information
Level value();
}
Example 9.6.2-3. Complex Annotation Type Declaration
Here is an example of a complex annotation type, that is, an annotation type that con-
tains one or more elements whose types are also annotation types.
Click here to view code image
/**
* A person's name. This annotation type is not designed
* to be used directly to annotate program elements, but to
* define elements of other annotation types.
*/
@interface Name {
String first();
String last();
}
/**
* Indicates the author of the annotated program element.
*/
@interface Author {
Name value();
}
/**
* Indicates the reviewer of the annotated program element.
*/
@interface Reviewer {
Name value();
}
9.6.2. Defaults for Annotation Type Elements
An annotation type element may have a default value specified for it. This is done by fol-
lowing its (empty) parameter list with the keyword default and the default value of the ele-
ment.
Defaults are applied dynamically at the time annotations are read; default values are not
compiled into annotations. Thus, changing a default value affects annotations even in
classes that were compiled before the change was made (presuming these annotations lack
an explicit value for the defaulted element).
An ElementValue (ยง 9.7 ) is used to specify a default value.
Search WWH ::




Custom Search