@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
AnnotationMirror s. |
protected QualifierKindHierarchy |
createQualifierKindHierarchy(Collection<Class<? extends Annotation>> qualifierClasses)
Create the
QualifierKindHierarchy . |
protected Set<AnnotationMirror> |
createTops()
Creates and returns the unmodifiable set of top
AnnotationMirror s. |
@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, wait
assertSameSize, assertSameSize, canHaveEmptyAnnotationSet, getWidth, greatestLowerBounds, isSubtype, isValid, leastUpperBounds, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBound
protected 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)
AnnotationMirror
s.AnnotationMirror
s@RequiresNonNull(value={"this.kindToAnnotationMirror","this.qualifierKindHierarchy"}) protected Set<AnnotationMirror> createBottoms(@UnderInitialization NoElementQualifierHierarchy this)
AnnotationMirror
s.AnnotationMirror
sprotected 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)
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 belongspublic 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 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 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 boolean isSubtype(AnnotationMirror subAnno, AnnotationMirror superAnno)
QualifierHierarchy
subQualifier
is equal to or a sub-qualifier of superQualifier
,
according to the type qualifier hierarchy.isSubtype
in interface QualifierHierarchy
subAnno
- possible subqualifier of superQualifier
superAnno
- possible superqualifier of subQualifier
subQualifier
is a subqualifier of, or equal to, superQualifier
public @Nullable AnnotationMirror leastUpperBound(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchy
qualifier1
and qualifier2
. Returns null
if the qualifiers are not from the same qualifier hierarchy.
Examples:
leastUpperBound
in interface QualifierHierarchy
a1
- the first qualifier; may not be in the same hierarchy as qualifier2
a2
- the second qualifier; may not be in the same hierarchy as qualifier1
null
if the qualifiers are from
different hierarchiespublic @Nullable AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchy
greatestLowerBound
in interface QualifierHierarchy
a1
- first qualifiera2
- second qualifier