Class NoElementQualifierHierarchy
java.lang.Object
org.checkerframework.framework.type.NoElementQualifierHierarchy
- All Implemented Interfaces:
QualifierHierarchy
- Direct Known Subclasses:
AliasingAnnotatedTypeFactory.AliasingQualifierHierarchy
@AnnotatedFor("nullness")
public class NoElementQualifierHierarchy
extends Object
implements QualifierHierarchy
A
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.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AnnotationMirrorSet
Set of bottom annotation mirrors.protected final Map<QualifierKind,
AnnotationMirror> Mapping fromQualifierKind
to its correspondingAnnotationMirror
.protected final QualifierKindHierarchy
protected final Set<? extends AnnotationMirror>
Set of all annotations in all the hierarchies.protected final AnnotationMirrorSet
Set of top annotation mirrors. -
Constructor Summary
ConstructorDescriptionNoElementQualifierHierarchy
(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements) Creates a NoElementQualifierHierarchy from the given classes. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 AnnotationMirrorSet
Creates and returns the unmodifiable set of bottomAnnotationMirror
s.protected QualifierKindHierarchy
createQualifierKindHierarchy
(Collection<Class<? extends Annotation>> qualifierClasses) Create theQualifierKindHierarchy
.protected AnnotationMirrorSet
Creates and returns the unmodifiable set of topAnnotationMirror
s.findAnnotationInHierarchy
(Collection<? extends AnnotationMirror> annos, AnnotationMirror top) Returns the annotation inqualifiers
that is in the hierarchy for whichtop
is top.findAnnotationInSameHierarchy
(Collection<? extends AnnotationMirror> annos, AnnotationMirror annotationMirror) Returns the annotation inqualifiers
that is in the same hierarchy asqualifier
.Return the bottom for the given qualifier, that is, the qualifier that is a subtype ofqualifier
but no further subtypes exist.Set<? extends AnnotationMirror>
Returns the bottom type qualifiers in the hierarchy.Returns the polymorphic qualifier for the hierarchy containingqualifier
, ornull
if there is no polymorphic qualifier in that hierarchy.protected QualifierKind
Returns theQualifierKind
for the given annotation.getTopAnnotation
(AnnotationMirror start) Return the top qualifier for the given qualifier, that is, the qualifier that is a supertype ofqualifier
but no further supertypes exist.Set<? extends AnnotationMirror>
Returns the top (ultimate super) type qualifiers in the type system.Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.boolean
isPolymorphicQualifier
(AnnotationMirror qualifier) Returnstrue
if the qualifier is a polymorphic qualifier; otherwise, returnsfalse
.boolean
isSubtype
(AnnotationMirror subAnno, AnnotationMirror superAnno) Tests whethersubQualifier
is equal to or a sub-qualifier ofsuperQualifier
, according to the type qualifier hierarchy.Returns the least upper bound (LUB) of the qualifiersqualifier1
andqualifier2
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.checkerframework.framework.type.QualifierHierarchy
getWidth, greatestLowerBounds, isSubtype, isValid, leastUpperBounds, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBound
-
Field Details
-
qualifierKindHierarchy
-
tops
Set of top annotation mirrors. -
bottoms
Set of bottom annotation mirrors. -
kindToAnnotationMirror
Mapping fromQualifierKind
to its correspondingAnnotationMirror
. -
qualifiers
Set of all annotations in all the hierarchies.
-
-
Constructor Details
-
NoElementQualifierHierarchy
public NoElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements) Creates a NoElementQualifierHierarchy from the given classes.- Parameters:
qualifierClasses
- classes of annotations that are the qualifierselements
- element utils
-
-
Method Details
-
createQualifierKindHierarchy
protected QualifierKindHierarchy createQualifierKindHierarchy(@UnderInitialization NoElementQualifierHierarchy this, Collection<Class<? extends Annotation>> qualifierClasses) Create theQualifierKindHierarchy
. (Subclasses may override to return a subclass of QualifierKindHierarchy.)- Parameters:
qualifierClasses
- classes of annotations that are the qualifiers- Returns:
- the newly created qualifier kind hierarchy
-
createAnnotationMirrors
@RequiresNonNull("this.qualifierKindHierarchy") protected Map<QualifierKind,AnnotationMirror> createAnnotationMirrors(@UnderInitialization NoElementQualifierHierarchy this, Elements elements) Creates and returns a mapping from qualifier kind to an annotation mirror created from the qualifier kind's annotation class.- Parameters:
elements
- element utils- Returns:
- a mapping from qualifier kind to its annotation mirror
-
createTops
@RequiresNonNull({"this.kindToAnnotationMirror","this.qualifierKindHierarchy"}) protected AnnotationMirrorSet createTops(@UnderInitialization NoElementQualifierHierarchy this) Creates and returns the unmodifiable set of topAnnotationMirror
s.- Returns:
- the unmodifiable set of top
AnnotationMirror
s
-
createBottoms
@RequiresNonNull({"this.kindToAnnotationMirror","this.qualifierKindHierarchy"}) protected AnnotationMirrorSet createBottoms(@UnderInitialization NoElementQualifierHierarchy this) Creates and returns the unmodifiable set of bottomAnnotationMirror
s.- Returns:
- the unmodifiable set of bottom
AnnotationMirror
s
-
getQualifierKind
Returns theQualifierKind
for the given annotation.- Parameters:
anno
- an annotation that is a qualifier in this- Returns:
- the
QualifierKind
for the given annotation
-
findAnnotationInSameHierarchy
public @Nullable AnnotationMirror findAnnotationInSameHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror annotationMirror) Description copied from interface:QualifierHierarchy
Returns the annotation inqualifiers
that is in the same hierarchy asqualifier
.The default implementation calls
QualifierHierarchy.getTopAnnotation(AnnotationMirror)
and then callsQualifierHierarchy.findAnnotationInHierarchy(Collection, AnnotationMirror)
. So, ifqualifier
is a top qualifier, then callQualifierHierarchy.findAnnotationInHierarchy(Collection, AnnotationMirror)
directly is faster.- Specified by:
findAnnotationInSameHierarchy
in interfaceQualifierHierarchy
- Parameters:
annos
- set of annotations to searchannotationMirror
- annotation that is in the same hierarchy as the returned annotation- Returns:
- annotation in the same hierarchy as qualifier, or null if one is not found
-
findAnnotationInHierarchy
public @Nullable AnnotationMirror findAnnotationInHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror top) Description copied from interface:QualifierHierarchy
Returns the annotation inqualifiers
that is in the hierarchy for whichtop
is top.- Specified by:
findAnnotationInHierarchy
in interfaceQualifierHierarchy
- Parameters:
annos
- set of annotations to searchtop
- the top annotation in the hierarchy to which the returned annotation belongs- Returns:
- annotation in the same hierarchy as annotationMirror, or null if one is not found
-
getTopAnnotations
Description copied from interface:QualifierHierarchy
Returns the top (ultimate super) type qualifiers in the type system. The size of this set is equal toQualifierHierarchy.getWidth()
.- Specified by:
getTopAnnotations
in interfaceQualifierHierarchy
- Returns:
- the top (ultimate super) type qualifiers in the type system
-
getTopAnnotation
Description copied from interface:QualifierHierarchy
Return the top qualifier for the given qualifier, that is, the qualifier that is a supertype ofqualifier
but no further supertypes exist.- Specified by:
getTopAnnotation
in interfaceQualifierHierarchy
- Parameters:
start
- any qualifier from one of the qualifier hierarchies represented by this- Returns:
- the top qualifier of
qualifier
's hierarchy
-
getBottomAnnotations
Description copied from interface:QualifierHierarchy
Returns the bottom type qualifiers in the hierarchy. The size of this set is equal toQualifierHierarchy.getWidth()
.- Specified by:
getBottomAnnotations
in interfaceQualifierHierarchy
- Returns:
- the bottom type qualifiers in the hierarchy
-
getBottomAnnotation
Description copied from interface:QualifierHierarchy
Return the bottom for the given qualifier, that is, the qualifier that is a subtype ofqualifier
but no further subtypes exist.- Specified by:
getBottomAnnotation
in interfaceQualifierHierarchy
- Parameters:
start
- any qualifier from one of the qualifier hierarchies represented by this- Returns:
- the bottom qualifier of
qualifier
's hierarchy
-
getPolymorphicAnnotation
Description copied from interface:QualifierHierarchy
Returns the polymorphic qualifier for the hierarchy containingqualifier
, ornull
if there is no polymorphic qualifier in that hierarchy.- Specified by:
getPolymorphicAnnotation
in interfaceQualifierHierarchy
- Parameters:
start
- any qualifier from one of the qualifier hierarchies represented by this- Returns:
- the polymorphic qualifier for the hierarchy containing
qualifier
, ornull
if there is no polymorphic qualifier in that hierarchy
-
isPolymorphicQualifier
Description copied from interface:QualifierHierarchy
Returnstrue
if the qualifier is a polymorphic qualifier; otherwise, returnsfalse
.- Specified by:
isPolymorphicQualifier
in interfaceQualifierHierarchy
- Parameters:
qualifier
- qualifier- Returns:
true
if the qualifier is a polymorphic qualifier; otherwise, returnsfalse
.
-
isSubtype
Description copied from interface:QualifierHierarchy
Tests whethersubQualifier
is equal to or a sub-qualifier ofsuperQualifier
, according to the type qualifier hierarchy.- Specified by:
isSubtype
in interfaceQualifierHierarchy
- Parameters:
subAnno
- possible subqualifier ofsuperQualifier
superAnno
- possible superqualifier ofsubQualifier
- Returns:
- true iff
subQualifier
is a subqualifier of, or equal to,superQualifier
-
leastUpperBound
Description copied from interface:QualifierHierarchy
Returns the least upper bound (LUB) of the qualifiersqualifier1
andqualifier2
. Returnsnull
if the qualifiers are not from the same qualifier hierarchy.Examples:
- For NonNull, leastUpperBound('Nullable', 'NonNull') ⇒ Nullable
- Specified by:
leastUpperBound
in interfaceQualifierHierarchy
- Parameters:
a1
- the first qualifier; may not be in the same hierarchy asqualifier2
a2
- the second qualifier; may not be in the same hierarchy asqualifier1
- Returns:
- the least upper bound of the qualifiers, or
null
if the qualifiers are from different hierarchies
-
greatestLowerBound
Description copied from interface:QualifierHierarchy
Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.- Specified by:
greatestLowerBound
in interfaceQualifierHierarchy
- Parameters:
a1
- first qualifiera2
- second qualifier- Returns:
- greatest lower bound of the two annotations or null if the two annotations are not from the same hierarchy
-