@Documented @Retention(value=RUNTIME) @Target(value=ANNOTATION_TYPE) public @interface DefaultFor
The default applies to every match for any of this annotation's conditions.
Modifier and Type | Optional Element and Description |
---|---|
String[] |
names
Returns regular expressions matching names of variables, to whose types the annotation should
be applied as a default.
|
String[] |
namesExceptions
Returns exceptions to regular expression rules.
|
TypeKind[] |
typeKinds
Returns
TypeKind s of types for which an annotation should be implicitly added. |
Class<?>[] |
types
Returns
Class es for which an annotation should be applied. |
TypeUseLocation[] |
value
Returns the locations to which the annotation should be applied.
|
public abstract TypeUseLocation[] value
public abstract Class<?>[] types
Class
es for which an annotation should be applied. For example, if
@MyAnno
is meta-annotated with @DefaultFor(classes=String.class)
, then every
occurrence of String
is actually @MyAnno String
.
Only the given types, not their subtypes, receive the default. For instance, if the types
element contains only Iterable
, then the default does not apply to a variable or
expression of type Collection
which is a subtype of Iterable
.
Class
es for which an annotation should be appliedpublic abstract String[] names
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:
-g
command-line option was provided.