@AnnotatedFor(value="nullness") public class NoElementQualifierHierarchy extends Object implements QualifierHierarchy
QualifierHierarchy where no qualifier has arguments; that is, no qualifier is
represented by an annotation with elements. The meta-annotation SubtypeOf specifies the subtyping relationships.
It uses a QualifierKindHierarchy to model the relationships between qualifiers.
Subclasses can override createQualifierKindHierarchy(Collection) to return a subclass of
QualifierKindHierarchy.
| Modifier and Type | Field and Description |
|---|---|
protected Set<AnnotationMirror> |
bottoms
Set of bottom annotation mirrors.
|
protected Map<QualifierKind,AnnotationMirror> |
kindToAnnotationMirror
Mapping from
QualifierKind to its corresponding AnnotationMirror. |
protected QualifierKindHierarchy |
qualifierKindHierarchy
|
protected Set<? extends AnnotationMirror> |
qualifiers
Set of all annotations in all the hierarchies.
|
protected Set<AnnotationMirror> |
tops
Set of top annotation mirrors.
|
| Constructor and Description |
|---|
NoElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses,
Elements elements)
Creates a NoElementQualifierHierarchy from the given classes.
|
| Modifier and Type | Method and Description |
|---|---|
protected Map<QualifierKind,AnnotationMirror> |
createAnnotationMirrors(Elements elements)
Creates and returns a mapping from qualifier kind to an annotation mirror created from the
qualifier kind's annotation class.
|
protected Set<AnnotationMirror> |
createBottoms()
Creates and returns the unmodifiable set of bottom
AnnotationMirrors. |
protected QualifierKindHierarchy |
createQualifierKindHierarchy(Collection<Class<? extends Annotation>> qualifierClasses)
Create the
QualifierKindHierarchy. |
protected Set<AnnotationMirror> |
createTops()
Creates and returns the unmodifiable set of top
AnnotationMirrors. |
@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
QualifierKind for the given annotation. |
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.
|
@Nullable AnnotationMirror |
greatestLowerBound(AnnotationMirror a1,
AnnotationMirror a2)
Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.
|
boolean |
isPolymorphicQualifier(AnnotationMirror qualifier)
Returns
true if the qualifier is a polymorphic qualifier; otherwise, returns false. |
boolean |
isSubtype(AnnotationMirror subAnno,
AnnotationMirror superAnno)
Tests whether
subQualifier is equal to or a sub-qualifier of superQualifier,
according to the type qualifier hierarchy. |
@Nullable AnnotationMirror |
leastUpperBound(AnnotationMirror a1,
AnnotationMirror a2)
Returns the least upper bound (LUB) of the qualifiers
qualifier1 and qualifier2. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitassertSameSize, assertSameSize, canHaveEmptyAnnotationSet, getWidth, greatestLowerBound, greatestLowerBounds, greatestLowerBounds, greatestLowerBoundsTypeVariable, greatestLowerBoundTypeVariable, isSubtype, isSubtype, isSubtype, isSubtypeTypeVariable, isSubtypeTypeVariable, isValid, leastUpperBound, leastUpperBounds, leastUpperBounds, leastUpperBoundsTypeVariable, leastUpperBoundTypeVariable, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBoundprotected final QualifierKindHierarchy qualifierKindHierarchy
protected final Set<AnnotationMirror> tops
protected final Set<AnnotationMirror> bottoms
protected final Map<QualifierKind,AnnotationMirror> kindToAnnotationMirror
QualifierKind to its corresponding AnnotationMirror.protected final Set<? extends AnnotationMirror> qualifiers
public NoElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements)
qualifierClasses - classes of annotations that are the qualifierselements - element utilsprotected QualifierKindHierarchy createQualifierKindHierarchy(@UnderInitialization NoElementQualifierHierarchy this, Collection<Class<? extends Annotation>> qualifierClasses)
QualifierKindHierarchy. (Subclasses may override to return a subclass of
QualifierKindHierarchy.)qualifierClasses - classes of annotations that are the qualifiers@RequiresNonNull(value="this.qualifierKindHierarchy") protected Map<QualifierKind,AnnotationMirror> createAnnotationMirrors(@UnderInitialization NoElementQualifierHierarchy this, Elements elements)
elements - element utils@RequiresNonNull(value={"this.kindToAnnotationMirror","this.qualifierKindHierarchy"}) protected Set<AnnotationMirror> createTops(@UnderInitialization NoElementQualifierHierarchy this)
AnnotationMirrors.AnnotationMirrors@RequiresNonNull(value={"this.kindToAnnotationMirror","this.qualifierKindHierarchy"}) protected Set<AnnotationMirror> createBottoms(@UnderInitialization NoElementQualifierHierarchy this)
AnnotationMirrors.AnnotationMirrorsprotected QualifierKind getQualifierKind(AnnotationMirror anno)
QualifierKind for the given annotation.anno - an annotation that is a qualifier in thisQualifierKind for the given annotationpublic @Nullable AnnotationMirror findAnnotationInSameHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror annotationMirror)
QualifierHierarchyqualifiers 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 QualifierHierarchyannos - 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)
QualifierHierarchyqualifiers that is in the hierarchy for which top is
top.findAnnotationInHierarchy in interface QualifierHierarchyannos - set of annotations to searchtop - the top annotation in the hierarchy to which the returned annotation belongspublic Set<? extends AnnotationMirror> getTopAnnotations()
QualifierHierarchyQualifierHierarchy.getWidth().getTopAnnotations in interface QualifierHierarchypublic AnnotationMirror getTopAnnotation(AnnotationMirror start)
QualifierHierarchyqualifier but no further supertypes exist.getTopAnnotation in interface QualifierHierarchystart - any qualifier from one of the qualifier hierarchies represented by thisqualifier's hierarchypublic Set<? extends AnnotationMirror> getBottomAnnotations()
QualifierHierarchyQualifierHierarchy.getWidth().getBottomAnnotations in interface QualifierHierarchypublic AnnotationMirror getBottomAnnotation(AnnotationMirror start)
QualifierHierarchyqualifier but no further subtypes exist.getBottomAnnotation in interface QualifierHierarchystart - any qualifier from one of the qualifier hierarchies represented by thisqualifier's hierarchypublic @Nullable AnnotationMirror getPolymorphicAnnotation(AnnotationMirror start)
QualifierHierarchyqualifier, or null if there is no polymorphic qualifier in that hierarchy.getPolymorphicAnnotation in interface QualifierHierarchystart - 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)
QualifierHierarchytrue if the qualifier is a polymorphic qualifier; otherwise, returns false.isPolymorphicQualifier in interface QualifierHierarchyqualifier - qualifiertrue if the qualifier is a polymorphic qualifier; otherwise, returns false.public boolean isSubtype(AnnotationMirror subAnno, AnnotationMirror superAnno)
QualifierHierarchysubQualifier is equal to or a sub-qualifier of superQualifier,
according to the type qualifier hierarchy.isSubtype in interface QualifierHierarchysubAnno - possible subqualifier of superQualifiersuperAnno - possible superqualifier of subQualifiersubQualifier is a subqualifier of, or equal to, superQualifierpublic @Nullable AnnotationMirror leastUpperBound(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchyqualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.
Examples:
leastUpperBound in interface QualifierHierarchya1 - the first qualifier; may not be in the same hierarchy as qualifier2a2 - the second qualifier; may not be in the same hierarchy as qualifier1null if the qualifiers are from
different hierarchiespublic @Nullable AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchygreatestLowerBound in interface QualifierHierarchya1 - first qualifiera2 - second qualifier