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
Modifier 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[]
ReturnsTypeKind
s of types for which an annotation should be implicitly added.Class<?>[]
ReturnsClass
es 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[] typeKindsReturnsTypeKind
s of types for which an annotation should be implicitly added.- Returns:
TypeKind
s of types for which an annotation should be implicitly added
- Default:
{}
-
types
Class<?>[] typesReturnsClass
es for which an annotation should be applied. For example, if@MyAnno
is meta-annotated with@DefaultFor(classes=String.class)
, then every occurrence ofString
is actually@MyAnno String
.Only the given types, not their subtypes, receive the default. For instance, if the
types
element contains onlyIterable
, then the default does not apply to a variable or expression of typeCollection
which is a subtype ofIterable
.- Returns:
Class
es 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
-g
command-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:
{}
-