@AnnotatedFor(value="nullness") public abstract class ElementQualifierHierarchy extends Object implements QualifierHierarchy
QualifierHierarchy
where qualifiers may be represented by annotations with elements.
ElementQualifierHierarchy uses a QualifierKindHierarchy
to model the relationships
between qualifiers. (By contrast, MostlyNoElementQualifierHierarchy
uses the QualifierKindHierarchy
to implement isSubtype
, leastUpperBound
, and greatestLowerBound
methods for qualifiers without elements.)
Subclasses can override createQualifierKindHierarchy(Collection)
to return a subclass
of QualifierKindHierarchy.
Modifier and Type | Field and Description |
---|---|
protected Set<AnnotationMirror> |
bottoms
The set of bottom annotation mirrors.
|
protected Map<QualifierKind,AnnotationMirror> |
bottomsMap
A mapping from bottom QualifierKinds to their corresponding AnnotationMirror.
|
protected Map<QualifierKind,AnnotationMirror> |
kindToElementlessQualifier
A mapping from QualifierKind to AnnotationMirror for all qualifiers whose annotations do not
have elements.
|
protected QualifierKindHierarchy |
qualifierKindHierarchy
|
protected Set<AnnotationMirror> |
tops
The set of top annotation mirrors.
|
protected Map<QualifierKind,AnnotationMirror> |
topsMap
A mapping from top QualifierKinds to their corresponding AnnotationMirror.
|
Modifier | Constructor and Description |
---|---|
protected |
ElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses,
Elements elements)
Creates a ElementQualifierHierarchy from the given classes.
|
Modifier and Type | Method and Description |
---|---|
protected Map<QualifierKind,AnnotationMirror> |
createBottomsMap()
Creates a mapping from QualifierKind to AnnotationMirror, where the QualifierKind is bottom
and the AnnotationMirror is bottom in their respective hierarchies.
|
protected Map<QualifierKind,AnnotationMirror> |
createElementlessQualifierMap()
Creates a mapping from QualifierKind to AnnotationMirror for all qualifiers whose annotations
do not have elements.
|
protected QualifierKindHierarchy |
createQualifierKindHierarchy(Collection<Class<? extends Annotation>> qualifierClasses)
Create the
QualifierKindHierarchy . |
protected Map<QualifierKind,AnnotationMirror> |
createTopsMap()
Creates a mapping from QualifierKind to AnnotationMirror, where the QualifierKind is top and
the AnnotationMirror is top in their respective hierarchies.
|
@Nullable AnnotationMirror |
findAnnotationInHierarchy(Collection<? extends AnnotationMirror> annos,
AnnotationMirror top)
Returns the annotation in
qualifiers that is in the hierarchy for which top
is top. |
@Nullable AnnotationMirror |
findAnnotationInSameHierarchy(Collection<? extends AnnotationMirror> annos,
AnnotationMirror annotationMirror)
Returns the annotation in
qualifiers that is in the same hierarchy as qualifier . |
AnnotationMirror |
getBottomAnnotation(AnnotationMirror start)
Return the bottom for the given qualifier, that is, the qualifier that is a subtype of
qualifier but no further subtypes exist. |
Set<? extends AnnotationMirror> |
getBottomAnnotations()
Returns the bottom type qualifiers in the hierarchy.
|
@Nullable AnnotationMirror |
getPolymorphicAnnotation(AnnotationMirror start)
Returns the polymorphic qualifier for the hierarchy containing
qualifier , or null if there is no polymorphic qualifier in that hierarchy. |
protected QualifierKind |
getQualifierKind(AnnotationMirror anno)
Returns the qualifier kind for the given annotation.
|
protected QualifierKind |
getQualifierKind(@CanonicalName String name)
Returns the qualifier kind for the annotation with the canonical name
name . |
AnnotationMirror |
getTopAnnotation(AnnotationMirror start)
Return the top qualifier for the given qualifier, that is, the qualifier that is a supertype
of
qualifier but no further supertypes exist. |
Set<? extends AnnotationMirror> |
getTopAnnotations()
Returns the top (ultimate super) type qualifiers in the type system.
|
boolean |
isPolymorphicQualifier(AnnotationMirror qualifier)
Returns
true if the qualifier is a polymorphic qualifier; otherwise, returns false . |
boolean |
isValid()
Determine whether this is valid.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
assertSameSize, assertSameSize, canHaveEmptyAnnotationSet, getWidth, greatestLowerBound, greatestLowerBound, greatestLowerBounds, greatestLowerBounds, greatestLowerBoundsTypeVariable, greatestLowerBoundTypeVariable, isSubtype, isSubtype, isSubtype, isSubtype, isSubtypeTypeVariable, isSubtypeTypeVariable, leastUpperBound, leastUpperBound, leastUpperBounds, leastUpperBounds, leastUpperBoundsTypeVariable, leastUpperBoundTypeVariable, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBound
protected final QualifierKindHierarchy qualifierKindHierarchy
protected final Map<QualifierKind,AnnotationMirror> topsMap
protected final Set<AnnotationMirror> tops
protected final Map<QualifierKind,AnnotationMirror> bottomsMap
protected final Set<AnnotationMirror> bottoms
protected final Map<QualifierKind,AnnotationMirror> kindToElementlessQualifier
protected ElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements)
qualifierClasses
- classes of annotations that are the qualifiers for this hierarchyelements
- element utilspublic boolean isValid()
QualifierHierarchy
isValid
in interface QualifierHierarchy
protected QualifierKindHierarchy createQualifierKindHierarchy(@UnderInitialization ElementQualifierHierarchy this, Collection<Class<? extends Annotation>> qualifierClasses)
QualifierKindHierarchy
. (Subclasses may override to return a subclass of
QualifierKindHierarchy.)qualifierClasses
- classes of annotations that are the qualifiers for this hierarchy@RequiresNonNull(value={"this.qualifierKindHierarchy","this.elements"}) protected Map<QualifierKind,AnnotationMirror> createElementlessQualifierMap(@UnderInitialization ElementQualifierHierarchy this)
@RequiresNonNull(value={"this.qualifierKindHierarchy","this.elements"}) protected Map<QualifierKind,AnnotationMirror> createTopsMap(@UnderInitialization ElementQualifierHierarchy this)
This implementation works if the top annotation has no elements, or if it has elements, provides a default, and that default is the top. Otherwise, subclasses must override this.
@RequiresNonNull(value={"this.qualifierKindHierarchy","this.elements"}) protected Map<QualifierKind,AnnotationMirror> createBottomsMap(@UnderInitialization ElementQualifierHierarchy this)
This implementation works if the bottom annotation has no elements, or if it has elements, provides a default, and that default is the bottom. Otherwise, subclasses must override this.
protected QualifierKind getQualifierKind(AnnotationMirror anno)
anno
- annotation mirrorprotected QualifierKind getQualifierKind(@CanonicalName String name)
name
.name
- fully qualified annotation namename
public Set<? extends AnnotationMirror> getTopAnnotations()
QualifierHierarchy
QualifierHierarchy.getWidth()
.getTopAnnotations
in interface QualifierHierarchy
public AnnotationMirror getTopAnnotation(AnnotationMirror start)
QualifierHierarchy
qualifier
but no further supertypes exist.getTopAnnotation
in interface QualifierHierarchy
start
- any qualifier from one of the qualifier hierarchies represented by thisqualifier
's hierarchypublic Set<? extends AnnotationMirror> getBottomAnnotations()
QualifierHierarchy
QualifierHierarchy.getWidth()
.getBottomAnnotations
in interface QualifierHierarchy
public @Nullable AnnotationMirror getPolymorphicAnnotation(AnnotationMirror start)
QualifierHierarchy
qualifier
, or null
if there is no polymorphic qualifier in that hierarchy.getPolymorphicAnnotation
in interface QualifierHierarchy
start
- any qualifier from one of the qualifier hierarchies represented by thisqualifier
, or null
if there is no polymorphic qualifier in that hierarchypublic boolean isPolymorphicQualifier(AnnotationMirror qualifier)
QualifierHierarchy
true
if the qualifier is a polymorphic qualifier; otherwise, returns false
.isPolymorphicQualifier
in interface QualifierHierarchy
qualifier
- qualifiertrue
if the qualifier is a polymorphic qualifier; otherwise, returns false
.public AnnotationMirror getBottomAnnotation(AnnotationMirror start)
QualifierHierarchy
qualifier
but no further subtypes exist.getBottomAnnotation
in interface QualifierHierarchy
start
- any qualifier from one of the qualifier hierarchies represented by thisqualifier
's hierarchypublic @Nullable AnnotationMirror findAnnotationInSameHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror annotationMirror)
QualifierHierarchy
qualifiers
that is in the same hierarchy as qualifier
.
The default implementation calls QualifierHierarchy.getTopAnnotation(AnnotationMirror)
and then
calls QualifierHierarchy.findAnnotationInHierarchy(Collection, AnnotationMirror)
. So, if qualifier
is a top qualifier, then call QualifierHierarchy.findAnnotationInHierarchy(Collection,
AnnotationMirror)
directly is faster.
findAnnotationInSameHierarchy
in interface QualifierHierarchy
annos
- set of annotations to searchannotationMirror
- annotation that is in the same hierarchy as the returned annotationpublic @Nullable AnnotationMirror findAnnotationInHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror top)
QualifierHierarchy
qualifiers
that is in the hierarchy for which top
is top.findAnnotationInHierarchy
in interface QualifierHierarchy
annos
- set of annotations to searchtop
- the top annotation in the hierarchy to which the returned annotation belongs