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
FieldsModifier and TypeFieldDescriptionprotected final AnnotationMirrorSetSet of bottom annotation mirrors.protected final Map<QualifierKind,AnnotationMirror> Mapping fromQualifierKindto its correspondingAnnotationMirror.protected final QualifierKindHierarchyprotected final Set<? extends AnnotationMirror>Set of all annotations in all the hierarchies.protected final AnnotationMirrorSetSet of top annotation mirrors. -
Constructor Summary
ConstructorsConstructorDescriptionNoElementQualifierHierarchy(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 AnnotationMirrorSetCreates and returns the unmodifiable set of bottomAnnotationMirrors.protected QualifierKindHierarchycreateQualifierKindHierarchy(Collection<Class<? extends Annotation>> qualifierClasses) Create theQualifierKindHierarchy.protected AnnotationMirrorSetCreates and returns the unmodifiable set of topAnnotationMirrors.findAnnotationInHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror top) Returns the annotation inqualifiersthat is in the hierarchy for whichtopis top.findAnnotationInSameHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror annotationMirror) Returns the annotation inqualifiersthat is in the same hierarchy asqualifier.Return the bottom for the given qualifier, that is, the qualifier that is a subtype ofqualifierbut no further subtypes exist.Returns the bottom type qualifiers in the hierarchy.Returns the polymorphic qualifier for the hierarchy containingqualifier, ornullif there is no polymorphic qualifier in that hierarchy.protected QualifierKindReturns theQualifierKindfor the given annotation.getTopAnnotation(AnnotationMirror start) Return the top qualifier for the given qualifier, that is, the qualifier that is a supertype ofqualifierbut no further supertypes exist.Returns the top (ultimate super) type qualifiers in the type system.Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.booleanisPolymorphicQualifier(AnnotationMirror qualifier) Returnstrueif the qualifier is a polymorphic qualifier; otherwise, returnsfalse.booleanisSubtype(AnnotationMirror subAnno, AnnotationMirror superAnno) Tests whethersubQualifieris equal to or a sub-qualifier ofsuperQualifier, according to the type qualifier hierarchy.Returns the least upper bound (LUB) of the qualifiersqualifier1andqualifier2.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 fromQualifierKindto 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 topAnnotationMirrors.- Returns:
- the unmodifiable set of top
AnnotationMirrors
-
createBottoms
@RequiresNonNull({"this.kindToAnnotationMirror","this.qualifierKindHierarchy"}) protected AnnotationMirrorSet createBottoms(@UnderInitialization NoElementQualifierHierarchy this) Creates and returns the unmodifiable set of bottomAnnotationMirrors.- Returns:
- the unmodifiable set of bottom
AnnotationMirrors
-
getQualifierKind
Returns theQualifierKindfor the given annotation.- Parameters:
anno- an annotation that is a qualifier in this- Returns:
- the
QualifierKindfor the given annotation
-
findAnnotationInSameHierarchy
public @Nullable AnnotationMirror findAnnotationInSameHierarchy(Collection<? extends AnnotationMirror> annos, AnnotationMirror annotationMirror) Description copied from interface:QualifierHierarchyReturns the annotation inqualifiersthat is in the same hierarchy asqualifier.The default implementation calls
QualifierHierarchy.getTopAnnotation(AnnotationMirror)and then callsQualifierHierarchy.findAnnotationInHierarchy(Collection, AnnotationMirror). So, ifqualifieris a top qualifier, then callQualifierHierarchy.findAnnotationInHierarchy(Collection, AnnotationMirror)directly is faster.- Specified by:
findAnnotationInSameHierarchyin 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:QualifierHierarchyReturns the annotation inqualifiersthat is in the hierarchy for whichtopis top.- Specified by:
findAnnotationInHierarchyin 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:QualifierHierarchyReturns the top (ultimate super) type qualifiers in the type system. The size of this set is equal toQualifierHierarchy.getWidth().- Specified by:
getTopAnnotationsin interfaceQualifierHierarchy- Returns:
- the top (ultimate super) type qualifiers in the type system
-
getTopAnnotation
Description copied from interface:QualifierHierarchyReturn the top qualifier for the given qualifier, that is, the qualifier that is a supertype ofqualifierbut no further supertypes exist.- Specified by:
getTopAnnotationin 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:QualifierHierarchyReturns the bottom type qualifiers in the hierarchy. The size of this set is equal toQualifierHierarchy.getWidth().- Specified by:
getBottomAnnotationsin interfaceQualifierHierarchy- Returns:
- the bottom type qualifiers in the hierarchy
-
getBottomAnnotation
Description copied from interface:QualifierHierarchyReturn the bottom for the given qualifier, that is, the qualifier that is a subtype ofqualifierbut no further subtypes exist.- Specified by:
getBottomAnnotationin 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:QualifierHierarchyReturns the polymorphic qualifier for the hierarchy containingqualifier, ornullif there is no polymorphic qualifier in that hierarchy.- Specified by:
getPolymorphicAnnotationin interfaceQualifierHierarchy- Parameters:
start- any qualifier from one of the qualifier hierarchies represented by this- Returns:
- the polymorphic qualifier for the hierarchy containing
qualifier, ornullif there is no polymorphic qualifier in that hierarchy
-
isPolymorphicQualifier
Description copied from interface:QualifierHierarchyReturnstrueif the qualifier is a polymorphic qualifier; otherwise, returnsfalse.- Specified by:
isPolymorphicQualifierin interfaceQualifierHierarchy- Parameters:
qualifier- qualifier- Returns:
trueif the qualifier is a polymorphic qualifier; otherwise, returnsfalse.
-
isSubtype
Description copied from interface:QualifierHierarchyTests whethersubQualifieris equal to or a sub-qualifier ofsuperQualifier, according to the type qualifier hierarchy.- Specified by:
isSubtypein interfaceQualifierHierarchy- Parameters:
subAnno- possible subqualifiersuperAnno- possible superqualifier- Returns:
- true iff
subQualifieris a subqualifier of, or equal to,superQualifier
-
leastUpperBound
Description copied from interface:QualifierHierarchyReturns the least upper bound (LUB) of the qualifiersqualifier1andqualifier2. Returnsnullif the qualifiers are not from the same qualifier hierarchy. Ignores Java basetypes.Examples:
- For NonNull, leastUpperBound('Nullable', 'NonNull') ⇒ Nullable
- Specified by:
leastUpperBoundin interfaceQualifierHierarchy- Parameters:
a1- the first qualifier; may not be in the same hierarchy asqualifier2a2- the second qualifier; may not be in the same hierarchy asqualifier1- Returns:
- the least upper bound of the qualifiers, or
nullif the qualifiers are from different hierarchies
-
greatestLowerBound
Description copied from interface:QualifierHierarchyReturns the greatest lower bound for the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.- Specified by:
greatestLowerBoundin 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
-