Annotation Interface DefaultQualifier
@Documented
@Retention(SOURCE)
@Target({PACKAGE,TYPE,CONSTRUCTOR,METHOD,FIELD,LOCAL_VARIABLE,PARAMETER})
@Repeatable(List.class)
public @interface DefaultQualifier
Applied to a declaration of a package, type, method, variable, etc., specifies that the given
annotation should be the default. The default is applied to type uses within the declaration for
which no other annotation is explicitly written. (The default is not applied to the "parametric
locations": class declarations, type parameter declarations, and type parameter uses.) If
multiple
DefaultQualifier annotations are in scope, the innermost one takes precedence.
DefaultQualifier takes precedence over DefaultQualifierInHierarchy.
You may write multiple @DefaultQualifier annotations (for unrelated type systems, or
with different locations fields) at the same location. For example:
@DefaultQualifier(NonNull.class)
@DefaultQualifier(value = NonNull.class, locations = TypeUseLocation.IMPLICIT_UPPER_BOUND)
@DefaultQualifier(Tainted.class)
class MyClass { ... }
Defaults on a package also apply to subpackages, unless the applyToSubpackages field
is set to false.
This annotation currently has no effect in stub files.
- See Also:
- See the Checker Framework Manual:
- Default qualifier for unannotated types
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceA wrapper annotation that makes theDefaultQualifierannotation repeatable. -
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionClass<? extends Annotation> The Class for the default annotation. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhen used on a package, whether the defaults should also apply to subpackages.Returns the locations to which the annotation should be applied.
-
Element Details
-
value
Class<? extends Annotation> valueThe Class for the default annotation.To prevent affecting other type systems, always specify an annotation in your own type hierarchy. (For example, do not set
Unqualifiedas the default.) -
locations
TypeUseLocation[] locationsReturns the locations to which the annotation should be applied.- Returns:
- the locations to which the annotation should be applied
- Default:
{ALL}
-
applyToSubpackages
boolean applyToSubpackagesWhen used on a package, whether the defaults should also apply to subpackages.- Returns:
- whether the default should be inherited by subpackages
- Default:
true
-