@Documented @Retention(value=RUNTIME) @Target(value=ANNOTATION_TYPE) public @interface SubtypeOf
QualifierHierarchy
or TypeHierarchy
.)
Example:
@SubtypeOf( { Nullable.class } ) public @interface NonNull { }
If a qualified type is a subtype of the same type without any qualifier, then use Unqualified.class
in place of a type qualifier class. For example, to express that
@Encrypted <em>C</em>
is a subtype of <em>C</em>
(for every class <em>C</em>
), and likewise for @Interned
, write:
@SubtypeOf(Unqualified.class) public @interface Encrypted { } @SubtypeOf(Unqualified.class) public @interface Interned { }
For the top qualifier in the qualifier hierarchy (i.e., the qualifier that is a supertype of all other qualifiers in the given hierarchy), use an empty set of values:
@SubtypeOf( { } ) public @interface Nullable { } @SubtypeOf( {} ) public @interface MaybeAliased { }
Together, all the @SubtypeOf meta-annotations fully describe the type qualifier hierarchy.
No @SubtypeOf meta-annotation is needed on (or can be written on) the Unqualified pseudo-qualifier, whose position in the hierarchy is inferred from the meta-annotations on the explicit qualifiers.
Modifier and Type | Required Element and Description |
---|---|
Class<? extends Annotation>[] |
value
An array of the supertype qualifiers of the annotated qualifier
|
public abstract Class<? extends Annotation>[] value