public abstract class AnnotatedTypeMirror
extends java.lang.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.AnnotatedUnionType |
static class |
AnnotatedTypeMirror.AnnotatedWildcardType
Represents a wildcard type argument.
|
Modifier and Type | Field and Description |
---|---|
protected javax.lang.model.type.TypeMirror |
actualType
Actual type wrapped with this AnnotatedTypeMirror
|
protected java.util.Set<javax.lang.model.element.AnnotationMirror> |
annotations
The annotations on this type.
|
protected AnnotatedTypeFactory |
atypeFactory
The factory to use for lazily creating annotated types.
|
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(javax.lang.model.element.AnnotationMirror a)
Adds an annotation to this type.
|
void |
addAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> a)
Adds an annotation to this type.
|
void |
addAnnotations(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> annotations)
Adds multiple annotations to this type.
|
void |
addMissingAnnotations(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> annotations)
Adds those annotations to the current type, for which no annotation
from the same qualifier hierarchy is present.
|
void |
clearAnnotations()
Removes all annotations on this type.
|
static AnnotatedTypeMirror |
createType(javax.lang.model.type.TypeMirror type,
AnnotatedTypeFactory atypeFactory)
Creates the appropriate AnnotatedTypeMirror specific wrapper for the
provided type
|
protected static AnnotatedTypeMirror.AnnotatedDeclaredType |
createTypeOfObject(AnnotatedTypeFactory atypeFactory) |
java.util.List<? extends AnnotatedTypeMirror> |
directSuperTypes() |
protected java.util.List<AnnotatedTypeMirror.AnnotatedDeclaredType> |
directSuperTypes(AnnotatedTypeMirror.AnnotatedDeclaredType type) |
boolean |
equals(java.lang.Object o) |
static java.lang.String |
formatAnnotationMirror(javax.lang.model.element.AnnotationMirror am)
Returns the string representation of a single AnnotationMirror, without showing full package names.
|
protected static void |
formatAnnotationMirror(javax.lang.model.element.AnnotationMirror am,
java.lang.StringBuilder sb) |
protected static void |
formatAnnotationMirrorArg(javax.lang.model.element.AnnotationValue av,
java.lang.StringBuilder sb) |
protected static java.lang.String |
formatAnnotationString(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> lst,
boolean printInvisible) |
javax.lang.model.element.AnnotationMirror |
getAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annoClass)
Returns the actual annotation mirror used to annotate this type,
whose name equals the passed annotationName if one exists, null otherwise.
|
javax.lang.model.element.AnnotationMirror |
getAnnotation(javax.lang.model.element.Name annotationName)
Returns the actual annotation mirror used to annotate this type,
whose name equals the passed annotationName if one exists, null otherwise.
|
javax.lang.model.element.AnnotationMirror |
getAnnotation(@Interned java.lang.String annotationStr)
Returns the actual annotation mirror used to annotate this type,
whose name equals the string argument if one exists, null otherwise.
|
javax.lang.model.element.AnnotationMirror |
getAnnotationInHierarchy(javax.lang.model.element.AnnotationMirror p)
Returns an annotation from the given sub-hierarchy, if such
an annotation targets this type; otherwise returns null.
|
java.util.Set<javax.lang.model.element.AnnotationMirror> |
getAnnotations()
Returns the annotations on this type.
|
abstract AnnotatedTypeMirror |
getCopy(boolean copyAnnotations)
Returns a shallow copy of this type.
|
javax.lang.model.element.AnnotationMirror |
getEffectiveAnnotationInHierarchy(javax.lang.model.element.AnnotationMirror p)
Returns an annotation from the given sub-hierarchy, if such
an annotation is present on this type or on its extends bounds;
otherwise returns null.
|
java.util.Set<javax.lang.model.element.AnnotationMirror> |
getEffectiveAnnotations()
Returns the "effective" annotations on this type, i.e.
|
AnnotatedTypeMirror |
getErased()
Returns the erasure type of the this type, according to JLS
specifications.
|
java.util.Set<javax.lang.model.element.AnnotationMirror> |
getExplicitAnnotations()
Returns the set of explicitly written annotations supported by this checker.
|
javax.lang.model.type.TypeKind |
getKind()
Returns the
kind of this type |
javax.lang.model.type.TypeMirror |
getUnderlyingType()
Returns the underlying unannotated Java type, which this wraps
|
boolean |
hasAnnotation(javax.lang.model.element.AnnotationMirror a)
Determines whether this type contains the given annotation.
|
boolean |
hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> a)
Determines whether this type contains an annotation with the same
annotation type as a particular annotation.
|
boolean |
hasAnnotation(javax.lang.model.element.Name a)
Determines whether this type contains the given annotation.
|
boolean |
hasAnnotationRelaxed(javax.lang.model.element.AnnotationMirror a)
Determines whether this type contains an annotation with the same
annotation type as a particular annotation.
|
boolean |
hasEffectiveAnnotation(javax.lang.model.element.AnnotationMirror a)
A version of hasAnnotation that considers annotations on the
upper bound of wildcards and type variables.
|
boolean |
hasEffectiveAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> a)
A version of hasAnnotation that considers annotations on the
upper bound of wildcards and type variables.
|
boolean |
hasEffectiveAnnotationRelaxed(javax.lang.model.element.AnnotationMirror a)
A version of hasAnnotationRelaxed that considers annotations on the
upper bound of wildcards and type variables.
|
boolean |
hasExplicitAnnotation(javax.lang.model.element.AnnotationMirror a)
Determines whether this type contains the given annotation
explicitly written at declaration.
|
boolean |
hasExplicitAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> a)
Determines whether this type contains an explictly written annotation
with the same annotation type as a particular annotation.
|
boolean |
hasExplicitAnnotationRelaxed(javax.lang.model.element.AnnotationMirror a)
A version of hasAnnotationRelaxed that only considers annotations that
are explicitly written on the type.
|
int |
hashCode() |
boolean |
isAnnotatedInHierarchy(javax.lang.model.element.AnnotationMirror p)
Returns true if an annotation from the given sub-hierarchy targets this type.
|
boolean |
removeAnnotation(javax.lang.model.element.AnnotationMirror a)
Removes an annotation from the type.
|
boolean |
removeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> a) |
boolean |
removeAnnotationInHierarchy(javax.lang.model.element.AnnotationMirror a)
Remove any annotation that is in the same qualifier hierarchy as the parameter.
|
boolean |
removeAnnotations(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> annotations)
Removes multiple annotations from the type.
|
boolean |
removeNonTopAnnotationInHierarchy(javax.lang.model.element.AnnotationMirror a)
Remove an annotation that is in the same qualifier hierarchy as the parameter,
unless it's the top annotation.
|
void |
replaceAnnotation(javax.lang.model.element.AnnotationMirror a)
Adds an annotation to this type, removing any existing annotation from the
same qualifier hierarchy first.
|
void |
replaceAnnotations(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> replAnnos)
Adds multiple annotations to this type, removing any existing annotations from the
same qualifier hierarchy first.
|
AnnotatedTypeMirror |
substitute(java.util.Map<? extends AnnotatedTypeMirror,? extends AnnotatedTypeMirror> mappings)
Return a copy of this, with the given substitutions performed.
|
java.lang.String |
toString() |
java.lang.String |
toString(boolean invisible)
A version of toString() that optionally outputs all type qualifiers,
including @InvisibleQualifier's.
|
java.lang.String |
toStringDebug() |
protected final AnnotatedTypeFactory atypeFactory
protected final javax.lang.model.type.TypeMirror actualType
protected final java.util.Set<javax.lang.model.element.AnnotationMirror> annotations
public static AnnotatedTypeMirror createType(javax.lang.model.type.TypeMirror type, AnnotatedTypeFactory atypeFactory)
type
- atypeFactory
- public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
@Pure public int hashCode()
hashCode
in class java.lang.Object
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 javax.lang.model.type.TypeKind getKind()
kind
of this typepublic javax.lang.model.type.TypeMirror getUnderlyingType()
public boolean isAnnotatedInHierarchy(javax.lang.model.element.AnnotationMirror p)
p
- The qualifier hierarchy to check for.public javax.lang.model.element.AnnotationMirror getAnnotationInHierarchy(javax.lang.model.element.AnnotationMirror p)
p
- The qualifier hierarchy to check for.public javax.lang.model.element.AnnotationMirror getEffectiveAnnotationInHierarchy(javax.lang.model.element.AnnotationMirror p)
p
- The qualifier hierarchy to check for.public java.util.Set<javax.lang.model.element.AnnotationMirror> getAnnotations()
public java.util.Set<javax.lang.model.element.AnnotationMirror> getEffectiveAnnotations()
public javax.lang.model.element.AnnotationMirror getAnnotation(javax.lang.model.element.Name annotationName)
annotationName
- public javax.lang.model.element.AnnotationMirror getAnnotation(@Interned java.lang.String annotationStr)
annotationStr
- public javax.lang.model.element.AnnotationMirror getAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annoClass)
annoClass
- annotation classpublic java.util.Set<javax.lang.model.element.AnnotationMirror> getExplicitAnnotations()
public boolean hasAnnotation(javax.lang.model.element.AnnotationMirror a)
hasAnnotationRelaxed(AnnotationMirror)
this method also compares annotation values.a
- the annotation to check fora
hasAnnotationRelaxed(AnnotationMirror)
public boolean hasAnnotation(javax.lang.model.element.Name a)
a
- the annotation name to check fora
hasAnnotationRelaxed(AnnotationMirror)
public boolean hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> a)
a
- the class of annotation to check fora
public boolean hasEffectiveAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> a)
hasAnnotation(Class)
public boolean hasEffectiveAnnotation(javax.lang.model.element.AnnotationMirror a)
hasAnnotation(AnnotationMirror)
public boolean hasExplicitAnnotation(javax.lang.model.element.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(javax.lang.model.element.AnnotationMirror a)
a
- the annotation to check fora
hasAnnotation(AnnotationMirror)
public boolean hasEffectiveAnnotationRelaxed(javax.lang.model.element.AnnotationMirror a)
hasAnnotationRelaxed(AnnotationMirror)
public boolean hasExplicitAnnotationRelaxed(javax.lang.model.element.AnnotationMirror a)
hasAnnotationRelaxed(AnnotationMirror)
public boolean hasExplicitAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> a)
a
- the class of annotation to check fora
public void addAnnotation(javax.lang.model.element.AnnotationMirror a)
TypeQualifier
meta-annotation, this method has no effect.a
- the annotation to addpublic void replaceAnnotation(javax.lang.model.element.AnnotationMirror a)
a
- the annotation to addpublic void addAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> a)
TypeQualifier
meta-annotation, this method has no effect.a
- the class of the annotation to addpublic void addAnnotations(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> annotations)
annotations
- the annotations to addpublic void addMissingAnnotations(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> annotations)
annotations
- the annotations to addpublic void replaceAnnotations(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> replAnnos)
replAnnos
- the annotations to replacepublic boolean removeAnnotation(javax.lang.model.element.AnnotationMirror a)
a
- the annotation to removepublic boolean removeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> a)
public boolean removeAnnotationInHierarchy(javax.lang.model.element.AnnotationMirror a)
a
- An annotation from the same qualifier hierarchypublic boolean removeNonTopAnnotationInHierarchy(javax.lang.model.element.AnnotationMirror a)
a
- An annotation from the same qualifier hierarchypublic boolean removeAnnotations(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> annotations)
annotations
- the annotations to removepublic void clearAnnotations()
removeAnnotation(AnnotationMirror)
and similar methods.@SideEffectFree protected static final java.lang.String formatAnnotationString(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> lst, boolean printInvisible)
protected static final void formatAnnotationMirror(javax.lang.model.element.AnnotationMirror am, java.lang.StringBuilder sb)
public static final java.lang.String formatAnnotationMirror(javax.lang.model.element.AnnotationMirror am)
protected static final void formatAnnotationMirrorArg(javax.lang.model.element.AnnotationValue av, java.lang.StringBuilder sb)
@SideEffectFree public final java.lang.String toString()
toString
in class java.lang.Object
@SideEffectFree public java.lang.String toString(boolean invisible)
invisible
- Whether to always output invisible qualifiers.@SideEffectFree public java.lang.String toStringDebug()
public AnnotatedTypeMirror getErased()
public abstract AnnotatedTypeMirror getCopy(boolean copyAnnotations)
copyAnnotations
- whether copy should have annotations, i.e. whether
field annotations
should be copied.protected static AnnotatedTypeMirror.AnnotatedDeclaredType createTypeOfObject(AnnotatedTypeFactory atypeFactory)
public AnnotatedTypeMirror substitute(java.util.Map<? extends AnnotatedTypeMirror,? extends AnnotatedTypeMirror> mappings)
mappings
- public java.util.List<? extends AnnotatedTypeMirror> directSuperTypes()
protected final java.util.List<AnnotatedTypeMirror.AnnotatedDeclaredType> directSuperTypes(AnnotatedTypeMirror.AnnotatedDeclaredType type)