Annotation Interface DefaultFor
A meta-annotation applied to the declaration of a type qualifier. It specifies that the given
annotation should be the default for:
- all uses at a particular location,
- all uses of a particular type, and
- all uses of a particular kind of type.
The default applies to every match for any of this annotation's conditions.
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]Returns regular expressions matching names of variables, to whose types the annotation should be applied as a default.String[]Returns exceptions to regular expression rules.TypeKind[]ReturnsTypeKinds of types for which an annotation should be implicitly added.Class<?>[]ReturnsClasses for which an annotation should be applied.Returns the locations to which the annotation should be applied.
-
Element Details
-
value
TypeUseLocation[] valueReturns the locations to which the annotation should be applied.- Returns:
- the locations to which the annotation should be applied
- Default:
{}
-
typeKinds
TypeKind[] typeKindsReturnsTypeKinds of types for which an annotation should be implicitly added.- Returns:
TypeKinds of types for which an annotation should be implicitly added
- Default:
{}
-
types
Class<?>[] typesReturnsClasses for which an annotation should be applied. For example, if@MyAnnois meta-annotated with@DefaultFor(classes=String.class), then every occurrence ofStringis actually@MyAnno String.Only the given types, not their subtypes, receive the default. For instance, if the
typeselement contains onlyIterable, then the default does not apply to a variable or expression of typeCollectionwhich is a subtype ofIterable.- Returns:
Classes for which an annotation should be applied
- Default:
{}
-
names
String[] namesReturns regular expressions matching names of variables, to whose types the annotation should be applied as a default. If a regular expression matches the name of a method, the annotation is applied as a default to the return type.The regular expression must match the entire variable or method name. For example, to match any name that contains "foo", use ".*foo.*".
The default does not apply if the name matches any of the regexes in
namesExceptions().This affects formal parameter types only if one of the following is true:
- The method's source code is available; that is, the method is type-checked along with client calls.
- When the method was compiled in a previous run of javac, either the processor was run
or the
-gcommand-line option was provided.
- Returns:
- regular expressions matching variables to whose type an annotation should be applied
- Default:
{}
-
namesExceptions
String[] namesExceptionsReturns exceptions to regular expression rules.- Returns:
- exceptions to regular expression rules
- See Also:
- Default:
{}
-