@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 |
String[] |
stringPatterns |
Class<?>[] |
typeNames |
TypeKind[] |
types |
public abstract LiteralKind[] literals
LiteralKinds 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 Class<?>[] typeNames
Classes (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.public abstract String[] stringPatterns