@Retention(value=RUNTIME)
@Target(value=ANNOTATION_TYPE)
public @interface ImplicitFor
For example, the Nullable
annotation is annotated with
@ImplicitFor(literals = LiteralKind.NULL)to denote that the literal
null
always has the type qualifier @Nullable
.Modifier and Type | Optional Element and Description |
---|---|
LiteralKind[] |
literals |
java.lang.String[] |
stringPatterns |
java.lang.Class<?>[] |
typeNames |
javax.lang.model.type.TypeKind[] |
types |
public abstract LiteralKind[] literals
LiteralKind
s for which an annotation should be implicitly added. For example,
if @MyAnno
is meta-annotated with
@ImplicitFor(literals={LiteralKind.STRING})
, then a literal String
constant such as "hello world"
has type @MyAnno String
, but other
occurrences of String
in the source code are not affected. For String literals,
also see the stringPatterns()
annotation field.public abstract javax.lang.model.type.TypeKind[] types
TypeKind
s of types for which an annotation should be implicitly addedpublic abstract java.lang.Class<?>[] typeNames
Class
es (in the actual program) for which an annotation should be implicitly
added. For example, if @MyAnno
is meta-annotated with
@ImplicitFor(typeNames=String.class)
, then every occurrence of String
is
actually @MyAnno String
. This has the same effect as writing the annotation on
the class definition (possibly in an annotated library):
class @MyAnno String {...}As another example, {code java.lang.Void.class} should receive the same annotation as the
null
literal.