Annotation Interface SubtypeOf

@Documented @Retention(RUNTIME) @Target(ANNOTATION_TYPE) public @interface SubtypeOf
A meta-annotation to specify all the qualifiers that the given qualifier is a subtype of. This provides a declarative way to specify the type qualifier hierarchy. (Alternatively, the hierarchy can be defined procedurally by subclassing checkers.types.QualifierHierarchy or checkers.types.TypeHierarchy.)


 @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 C is a subtype of C (for every class C), and likewise for @Interned, write:

 public @interface Encrypted { }

 public @interface Interned { }

For the root type 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 ReadOnly { }

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.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Class<? extends Annotation>[]
  • Element Details

    • value

      Class<? extends Annotation>[] value
      supertype qualifiers of the annotated qualifier