public abstract class AnnotatedTypeMirror extends @NonNull Object
void.
Types should be compared using the utility methods in AnnotatedTypes. There is no guarantee that any particular type will always
be represented by the same object.
To implement operations based on the class of an AnnotatedTypeMirror object, either
use a visitor or use the result of the getKind() method.
TypeMirror| Modifier and Type | Class and Description |
|---|---|
static class |
AnnotatedTypeMirror.AnnotatedArrayType
Represents Array types in java.
|
static class |
AnnotatedTypeMirror.AnnotatedDeclaredType
Represents a declared type (whether class or interface).
|
static class |
AnnotatedTypeMirror.AnnotatedExecutableType
Represents a type of an executable.
|
static class |
AnnotatedTypeMirror.AnnotatedNoType
A pseudo-type used where no actual type is appropriate.
|
static class |
AnnotatedTypeMirror.AnnotatedNullType
Represents the null type.
|
static class |
AnnotatedTypeMirror.AnnotatedPrimitiveType
Represents a primitive type.
|
static interface |
AnnotatedTypeMirror.AnnotatedReferenceType |
static class |
AnnotatedTypeMirror.AnnotatedTypeVariable
Represents a type variable.
|
static class |
AnnotatedTypeMirror.AnnotatedWildcardType
Represents a wildcard type argument.
|
| Modifier and Type | Field and Description |
|---|---|
protected TypeMirror |
actualType
Actual type wrapped with this AnnotatedTypeMirror
|
protected AnnotationUtils |
annotationFactory
The factory to use for lazily creating annotations.
|
protected Set<@Nullable AnnotationMirror> |
annotations
The annotations on this type.
|
protected @Nullable Element |
element
the Element associated with this instance value, if one exists
|
protected @Mutable AnnotatedTypeMirror |
enclosingType
The enclosing Type
|
protected ProcessingEnvironment |
env
Processing Environment of the current round
|
protected AnnotatedTypeFactory |
typeFactory
The factory to use for lazily creating annotated types.
|
int |
uid |
| Modifier and Type | Method and Description |
|---|---|
abstract <R extends @NonNull Object,P extends @NonNull Object> |
accept(AnnotatedTypeVisitor<R,P> v,
P p)
Applies a visitor to this type.
|
void |
addAnnotation(@Nullable AnnotationMirror a)
Adds an annotation to this type.
|
void |
addAnnotation(Class<? extends Annotation> a)
Adds an annotation to this type.
|
void |
addAnnotations(Iterable<? extends @Nullable AnnotationMirror> annotations)
Adds multiple annotations to this type.
|
void |
clearAnnotations()
Removes all annotations on this type.
|
protected @Mutable AnnotatedTypeMirror |
copyFields(@Mutable AnnotatedTypeMirror type,
boolean annotation)
Copy the fields on this type onto the passed type.
|
static @Mutable AnnotatedTypeMirror |
createType(TypeMirror type,
ProcessingEnvironment env,
AnnotatedTypeFactory typeFactory)
Creates the appropriate AnnotatedTypeMirror specific wrapper for the
provided type
|
protected static AnnotatedTypeMirror.AnnotatedDeclaredType |
createTypeOfObject(AnnotatedTypeFactory typeFactory) |
List<? extends @Mutable AnnotatedTypeMirror> |
directSuperTypes() |
protected List<AnnotatedTypeMirror.AnnotatedDeclaredType> |
directSuperTypes(AnnotatedTypeMirror.AnnotatedDeclaredType type) |
boolean |
equals(@NonNull Object o) |
protected static @ReadOnly String |
formatAnnotationString(ProcessingEnvironment env,
Collection<? extends @Nullable AnnotationMirror> lst,
boolean printInvisible) |
@Nullable AnnotationMirror |
getAnnotation(Class<? extends Annotation> anno)
Returns the actual annotation mirror used to annotate this type,
whose name equals the passed annotationName if one exists, null otherwise.
|
@Nullable AnnotationMirror |
getAnnotation(@Nullable Name annotationName)
Returns the actual annotation mirror used to annotate this type,
whose name equals the passed annotationName if one exists, null otherwise.
|
@Nullable AnnotationMirror |
getAnnotation(@ReadOnly String annotationName)
Returns the actual annotation mirror used to annotate this type,
whose name equals the passed annotationName if one exists, null otherwise.
|
@Nullable AnnotationMirror |
getAnnotationInHierarchy(@Nullable AnnotationMirror p)
Returns an annotation from the given sub-hierarchy, if such
an annotation targets this type; otherwise returns null.
|
Set<@Nullable AnnotationMirror> |
getAnnotations()
Returns the annotations on this type.
|
abstract @Mutable AnnotatedTypeMirror |
getCopy(boolean copyAnnotations)
Returns a shallow copy of this type.
|
Set<@Nullable AnnotationMirror> |
getEffectiveAnnotations()
Returns the "effective" annotations on this type, i.e.
|
@Nullable Element |
getElement()
Returns the element associated with the value the type represent, if any.
|
@Mutable AnnotatedTypeMirror |
getEnclosingType()
Returns the enclosing type, as in the type of
A in the type
A.B. |
@Mutable AnnotatedTypeMirror |
getErased()
Returns the erasure type of the this type, according to JLS
specifications.
|
Set<@Nullable AnnotationMirror> |
getExplicitAnnotations()
Returns the set of explicitly written annotations supported by this checker.
|
TypeKind |
getKind()
Returns the
kind of this type |
TypeMirror |
getUnderlyingType()
Returns the underlying unannotated Java type, which this wraps
|
boolean |
hasAnnotation(@Nullable AnnotationMirror a)
Determines whether this type contains the given annotation.
|
boolean |
hasAnnotation(Class<? extends Annotation> a)
Determines whether this type contains an annotation with the same
annotation type as a particular annotation.
|
boolean |
hasAnnotationRelaxed(@Nullable AnnotationMirror a)
Determines whether this type contains an annotation with the same
annotation type as a particular annotation.
|
boolean |
hasEffectiveAnnotation(@Nullable AnnotationMirror a)
A version of hasAnnotation that considers annotations on the
upper bound of wildcards and type variables.
|
boolean |
hasEffectiveAnnotationRelaxed(@Nullable AnnotationMirror a)
A version of hasAnnotationRelaxed that considers annotations on the
upper bound of wildcards and type variables.
|
boolean |
hasExplicitAnnotation(@Nullable AnnotationMirror a)
Determines whether this type contains the given annotation
explicitly written at declaration.
|
boolean |
hasExplicitAnnotation(Class<? extends Annotation> a)
Determines whether this type contains an explictly written annotation
with the same annotation type as a particular annotation.
|
boolean |
hasExplicitAnnotationRelaxed(@Nullable AnnotationMirror a)
A version of hasAnnotationRelaxed that only considers annotations that
are explicitly written on the type.
|
int |
hashCode() |
boolean |
isAnnotated()
Returns true if an annotation targets this type location.
|
boolean |
isAnnotatedInHierarchy(@Nullable AnnotationMirror p)
Returns true if an annotation from the given sub-hierarchy targets this type.
|
static boolean |
isUnqualified(@Nullable AnnotationMirror anno) |
boolean |
removeAnnotation(@Nullable AnnotationMirror a)
Removes an annotation from the type.
|
boolean |
removeAnnotation(Class<? extends Annotation> a) |
boolean |
removeAnnotationInHierarchy(@Nullable AnnotationMirror a)
Remove any annotation that is in the same qualifier hierarchy as the parameter.
|
boolean |
removeAnnotations(Iterable<? extends @Nullable AnnotationMirror> annotations)
Removes multiple annotations from the type.
|
void |
removeUnqualified()
Remove an Unqualified annotation if it exists.
|
void |
replaceAnnotation(@Nullable AnnotationMirror a)
Adds an annotation to this type, removing any existing annotation from the
same qualifier hierarchy first.
|
void |
replaceAnnotations(Iterable<? extends @Nullable AnnotationMirror> replAnnos)
Adds multiple annotations to this type, removing any existing annotations from the
same qualifier hierarchy first.
|
@Mutable AnnotatedTypeMirror |
substitute(Map<? extends @Mutable AnnotatedTypeMirror,? extends @Mutable AnnotatedTypeMirror> mappings)
Return a copy of this, with the given substitutions performed.
|
@ReadOnly String |
toString() |
@ReadOnly String |
toString(boolean invisible)
A version of toString() that optionally outputs all type qualifiers,
including @InvisibleQualifier's.
|
@ReadOnly String |
toStringDebug() |
protected final ProcessingEnvironment env
protected final AnnotationUtils annotationFactory
protected final AnnotatedTypeFactory typeFactory
protected final TypeMirror actualType
protected @Nullable Element element
protected @Mutable AnnotatedTypeMirror enclosingType
protected final Set<@Nullable AnnotationMirror> annotations
public int uid
public static @Mutable AnnotatedTypeMirror createType(TypeMirror type, ProcessingEnvironment env, AnnotatedTypeFactory typeFactory)
type - env - typeFactory - public List<? extends @Mutable AnnotatedTypeMirror> directSuperTypes()
public abstract <R extends @NonNull Object,P extends @NonNull Object> R accept(AnnotatedTypeVisitor<R,P> v, P p)
R - the return type of the visitor's methodsP - the type of the additional parameter to the visitor's methodsv - the visitor operating on this typep - additional parameter to the visitorpublic TypeKind getKind()
kind of this typepublic TypeMirror getUnderlyingType()
public @Mutable AnnotatedTypeMirror getEnclosingType()
A in the type
A.B.public boolean isAnnotated()
public boolean isAnnotatedInHierarchy(@Nullable AnnotationMirror p)
p - The qualifier hierarchy to check for.public @Nullable AnnotationMirror getAnnotationInHierarchy(@Nullable AnnotationMirror p)
p - The qualifier hierarchy to check for.public Set<@Nullable AnnotationMirror> getAnnotations()
public Set<@Nullable AnnotationMirror> getEffectiveAnnotations()
public @Nullable AnnotationMirror getAnnotation(@ReadOnly String annotationName)
annotationName - public @Nullable AnnotationMirror getAnnotation(@Nullable Name annotationName)
annotationName - public @Nullable AnnotationMirror getAnnotation(Class<? extends Annotation> anno)
anno - annotation classpublic Set<@Nullable AnnotationMirror> getExplicitAnnotations()
public boolean hasAnnotation(@Nullable AnnotationMirror a)
hasAnnotationRelaxed(AnnotationMirror)
this method also compares annotation values.a - the annotation to check forahasAnnotationRelaxed(AnnotationMirror)public boolean hasEffectiveAnnotation(@Nullable AnnotationMirror a)
hasAnnotation(AnnotationMirror)public boolean hasExplicitAnnotation(@Nullable AnnotationMirror a)
hasExplicitAnnotationRelaxed(AnnotationMirror)
this method also compares annotation values.a - the annotation to check fora is explicitly written
on the typehasExplicitAnnotationRelaxed(AnnotationMirror)public boolean hasAnnotationRelaxed(@Nullable AnnotationMirror a)
a - the annotation to check forahasAnnotation(AnnotationMirror)public boolean hasEffectiveAnnotationRelaxed(@Nullable AnnotationMirror a)
public boolean hasExplicitAnnotationRelaxed(@Nullable AnnotationMirror a)
public boolean hasAnnotation(Class<? extends Annotation> a)
a - the class of annotation to check forapublic boolean hasExplicitAnnotation(Class<? extends Annotation> a)
a - the class of annotation to check forapublic void addAnnotation(@Nullable AnnotationMirror a)
TypeQualifier meta-annotation, this method has no effect.a - the annotation to addpublic void replaceAnnotation(@Nullable AnnotationMirror a)
a - the annotation to addpublic void addAnnotation(Class<? extends Annotation> a)
TypeQualifier meta-annotation, this method has no effect.a - the class of the annotation to addpublic void addAnnotations(Iterable<? extends @Nullable AnnotationMirror> annotations)
annotations - the annotations to addpublic void replaceAnnotations(Iterable<? extends @Nullable AnnotationMirror> replAnnos)
replAnnos - the annotations to replacepublic boolean removeAnnotation(@Nullable AnnotationMirror a)
a - the annotation to removepublic boolean removeAnnotation(Class<? extends Annotation> a)
public boolean removeAnnotationInHierarchy(@Nullable AnnotationMirror a)
a - An annotation from the same qualifier hierarchypublic void removeUnqualified()
public boolean removeAnnotations(Iterable<? extends @Nullable AnnotationMirror> annotations)
annotations - the annotations to removepublic void clearAnnotations()
public static boolean isUnqualified(@Nullable AnnotationMirror anno)
protected static final @ReadOnly String formatAnnotationString(ProcessingEnvironment env, Collection<? extends @Nullable AnnotationMirror> lst, boolean printInvisible)
public @ReadOnly String toString(boolean invisible)
invisible - Whether to always output invisible qualifiers.public @Nullable Element getElement()
Element of the value of this type, if one existspublic @Mutable AnnotatedTypeMirror getErased()
protected @Mutable AnnotatedTypeMirror copyFields(@Mutable AnnotatedTypeMirror type, boolean annotation)
AnnotatedTypeMirror.
TODO: None of the subtypes in this compilation unit override this method, however.
Is this documentation inconsistent? Or should we add these implementations?
The separation between copyFields and getCopy is unclear.type - an empty type where fields of this are copied toannotation - whether annotations are copied or notpublic abstract @Mutable AnnotatedTypeMirror getCopy(boolean copyAnnotations)
copyAnnotations - whether copy should have annotationsprotected static AnnotatedTypeMirror.AnnotatedDeclaredType createTypeOfObject(AnnotatedTypeFactory typeFactory)
public @Mutable AnnotatedTypeMirror substitute(Map<? extends @Mutable AnnotatedTypeMirror,? extends @Mutable AnnotatedTypeMirror> mappings)
mappings - protected final List<AnnotatedTypeMirror.AnnotatedDeclaredType> directSuperTypes(AnnotatedTypeMirror.AnnotatedDeclaredType type)