public abstract class AnnotatedTypeMirror extends 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.AnnotatedIntersectionType |
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 Set<AnnotationMirror> |
annotations
The annotations on this type.
|
protected AnnotatedTypeFactory |
atypeFactory
The factory to use for lazily creating annotated types.
|
protected Element |
element
the Element associated with this instance value, if one exists
|
Modifier and Type | Method and Description |
---|---|
abstract <R,P> R |
accept(AnnotatedTypeVisitor<R,P> v,
P p)
Applies a visitor to this type.
|
void |
addAnnotation(AnnotationMirror a)
Adds an annotation to this type.
|
void |
addAnnotation(Class<? extends Annotation> a)
Adds an annotation to this type.
|
void |
addAnnotations(Iterable<? extends AnnotationMirror> annotations)
Adds multiple annotations to this type.
|
void |
clearAnnotations()
Removes all annotations on this type.
|
protected AnnotatedTypeMirror |
copyFields(AnnotatedTypeMirror type,
boolean annotation)
Copy the fields on this type onto the passed type.
|
static AnnotatedTypeMirror |
createType(TypeMirror type,
AnnotatedTypeFactory atypeFactory)
Creates the appropriate AnnotatedTypeMirror specific wrapper for the
provided type
|
protected static AnnotatedTypeMirror.AnnotatedDeclaredType |
createTypeOfObject(AnnotatedTypeFactory atypeFactory) |
List<? extends AnnotatedTypeMirror> |
directSuperTypes() |
protected List<AnnotatedTypeMirror.AnnotatedDeclaredType> |
directSuperTypes(AnnotatedTypeMirror.AnnotatedDeclaredType type) |
boolean |
equals(Object o) |
protected static void |
formatAnnotationMirror(AnnotationMirror am,
StringBuilder sb) |
protected static void |
formatAnnotationMirrorArg(AnnotationValue av,
StringBuilder sb) |
protected static String |
formatAnnotationString(Collection<? extends AnnotationMirror> lst,
boolean printInvisible) |
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.
|
AnnotationMirror |
getAnnotation(Name annotationName)
Returns the actual annotation mirror used to annotate this type,
whose name equals the passed annotationName if one exists, null otherwise.
|
AnnotationMirror |
getAnnotationInHierarchy(AnnotationMirror p)
Returns an annotation from the given sub-hierarchy, if such
an annotation targets this type; otherwise returns null.
|
Set<AnnotationMirror> |
getAnnotations()
Returns the annotations on this type.
|
abstract AnnotatedTypeMirror |
getCopy(boolean copyAnnotations)
Returns a shallow copy of this type.
|
Set<AnnotationMirror> |
getEffectiveAnnotations()
Returns the "effective" annotations on this type, i.e.
|
Element |
getElement()
Returns the element associated with the value the type represent, if any.
|
AnnotatedTypeMirror |
getErased()
Returns the erasure type of the this type, according to JLS
specifications.
|
Set<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(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 |
hasAnnotation(Name a)
Determines whether this type contains the given annotation.
|
boolean |
hasAnnotationRelaxed(AnnotationMirror a)
Determines whether this type contains an annotation with the same
annotation type as a particular annotation.
|
boolean |
hasEffectiveAnnotation(AnnotationMirror a)
A version of hasAnnotation that considers annotations on the
upper bound of wildcards and type variables.
|
boolean |
hasEffectiveAnnotationRelaxed(AnnotationMirror a)
A version of hasAnnotationRelaxed that considers annotations on the
upper bound of wildcards and type variables.
|
boolean |
hasExplicitAnnotation(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(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(AnnotationMirror p)
Returns true if an annotation from the given sub-hierarchy targets this type.
|
static boolean |
isUnqualified(AnnotationMirror anno) |
boolean |
removeAnnotation(AnnotationMirror a)
Removes an annotation from the type.
|
boolean |
removeAnnotation(Class<? extends Annotation> a) |
boolean |
removeAnnotationInHierarchy(AnnotationMirror a)
Remove any annotation that is in the same qualifier hierarchy as the parameter.
|
boolean |
removeAnnotations(Iterable<? extends AnnotationMirror> annotations)
Removes multiple annotations from the type.
|
void |
replaceAnnotation(AnnotationMirror a)
Adds an annotation to this type, removing any existing annotation from the
same qualifier hierarchy first.
|
void |
replaceAnnotations(Iterable<? extends AnnotationMirror> replAnnos)
Adds multiple annotations to this type, removing any existing annotations from the
same qualifier hierarchy first.
|
AnnotatedTypeMirror |
substitute(Map<? extends AnnotatedTypeMirror,? extends AnnotatedTypeMirror> mappings)
Return a copy of this, with the given substitutions performed.
|
String |
toString() |
String |
toString(boolean invisible)
A version of toString() that optionally outputs all type qualifiers,
including @InvisibleQualifier's.
|
String |
toStringDebug() |
protected final AnnotatedTypeFactory atypeFactory
protected final TypeMirror actualType
protected Element element
protected final Set<AnnotationMirror> annotations
public static AnnotatedTypeMirror createType(TypeMirror type, AnnotatedTypeFactory atypeFactory)
type
- env
- atypeFactory
- public abstract <R,P> 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 boolean isAnnotated()
public boolean isAnnotatedInHierarchy(AnnotationMirror p)
p
- The qualifier hierarchy to check for.public AnnotationMirror getAnnotationInHierarchy(AnnotationMirror p)
p
- The qualifier hierarchy to check for.public Set<AnnotationMirror> getAnnotations()
public Set<AnnotationMirror> getEffectiveAnnotations()
public AnnotationMirror getAnnotation(Name annotationName)
annotationName
- public AnnotationMirror getAnnotation(Class<? extends Annotation> anno)
anno
- annotation classpublic Set<AnnotationMirror> getExplicitAnnotations()
public boolean hasAnnotation(AnnotationMirror a)
hasAnnotationRelaxed(AnnotationMirror)
this method also compares annotation values.a
- the annotation to check fora
hasAnnotationRelaxed(AnnotationMirror)
public boolean hasAnnotation(Name a)
a
- the annotation name to check fora
hasAnnotationRelaxed(AnnotationMirror)
public boolean hasAnnotation(Class<? extends Annotation> a)
a
- the class of annotation to check fora
public boolean hasEffectiveAnnotation(AnnotationMirror a)
hasAnnotation(AnnotationMirror)
public boolean hasExplicitAnnotation(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(AnnotationMirror a)
a
- the annotation to check fora
hasAnnotation(AnnotationMirror)
public boolean hasEffectiveAnnotationRelaxed(AnnotationMirror a)
hasAnnotationRelaxed(AnnotationMirror)
public boolean hasExplicitAnnotationRelaxed(AnnotationMirror a)
hasAnnotationRelaxed(AnnotationMirror)
public boolean hasExplicitAnnotation(Class<? extends Annotation> a)
a
- the class of annotation to check fora
public void addAnnotation(AnnotationMirror a)
TypeQualifier
meta-annotation, this method has no effect.a
- the annotation to addpublic void replaceAnnotation(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 AnnotationMirror> annotations)
annotations
- the annotations to addpublic void replaceAnnotations(Iterable<? extends AnnotationMirror> replAnnos)
replAnnos
- the annotations to replacepublic boolean removeAnnotation(AnnotationMirror a)
a
- the annotation to removepublic boolean removeAnnotation(Class<? extends Annotation> a)
public boolean removeAnnotationInHierarchy(AnnotationMirror a)
a
- An annotation from the same qualifier hierarchypublic boolean removeAnnotations(Iterable<? extends AnnotationMirror> annotations)
annotations
- the annotations to removepublic void clearAnnotations()
public static boolean isUnqualified(AnnotationMirror anno)
protected static final String formatAnnotationString(Collection<? extends AnnotationMirror> lst, boolean printInvisible)
protected static final void formatAnnotationMirror(AnnotationMirror am, StringBuilder sb)
protected static final void formatAnnotationMirrorArg(AnnotationValue av, StringBuilder sb)
public String toString(boolean invisible)
invisible
- Whether to always output invisible qualifiers.public String toStringDebug()
public Element getElement()
Element
of the value of this type, if one existspublic AnnotatedTypeMirror getErased()
protected AnnotatedTypeMirror copyFields(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 AnnotatedTypeMirror getCopy(boolean copyAnnotations)
copyAnnotations
- whether copy should have annotationsprotected static AnnotatedTypeMirror.AnnotatedDeclaredType createTypeOfObject(AnnotatedTypeFactory atypeFactory)
public AnnotatedTypeMirror substitute(Map<? extends AnnotatedTypeMirror,? extends AnnotatedTypeMirror> mappings)
mappings
- public List<? extends AnnotatedTypeMirror> directSuperTypes()
protected final List<AnnotatedTypeMirror.AnnotatedDeclaredType> directSuperTypes(AnnotatedTypeMirror.AnnotatedDeclaredType type)