Class MostlyNoElementQualifierHierarchy
java.lang.Object
org.checkerframework.framework.type.ElementQualifierHierarchy
org.checkerframework.framework.type.MostlyNoElementQualifierHierarchy
- All Implemented Interfaces:
QualifierHierarchy
- Direct Known Subclasses:
FenumAnnotatedTypeFactory.FenumQualifierHierarchy,InitializationAnnotatedTypeFactory.InitializationQualifierHierarchy,SubtypeIsSubsetQualifierHierarchy,SubtypeIsSupersetQualifierHierarchy,UnitsAnnotatedTypeFactory.UnitsQualifierHierarchy
@AnnotatedFor("nullness")
public abstract class MostlyNoElementQualifierHierarchy
extends ElementQualifierHierarchy
A
QualifierHierarchy where qualifiers may be
represented by annotations with elements, but most of the qualifiers do not have elements. In
contrast to ElementQualifierHierarchy, this class
partially implements isSubtype(AnnotationMirror, AnnotationMirror), leastUpperBound(AnnotationMirror, AnnotationMirror), and greatestLowerBound(AnnotationMirror, AnnotationMirror) and calls *WithElements when the result
cannot be computed from the meta-annotations SubtypeOf.
Subclasses must implement the following methods when annotations have elements:
isSubtypeWithElements(AnnotationMirror, QualifierKind, AnnotationMirror, QualifierKind)leastUpperBoundWithElements(AnnotationMirror, QualifierKind, AnnotationMirror, QualifierKind,QualifierKind)greatestLowerBoundWithElements(AnnotationMirror, QualifierKind, AnnotationMirror, QualifierKind,QualifierKind)
MostlyNoElementQualifierHierarchy uses a QualifierKindHierarchy to model the
relationships between qualifiers. Subclasses can override ElementQualifierHierarchy.createQualifierKindHierarchy(Collection) to return a subclass of QualifierKindHierarchy.
-
Field Summary
Fields inherited from class org.checkerframework.framework.type.ElementQualifierHierarchy
bottoms, bottomsMap, kindToElementlessQualifier, qualifierKindHierarchy, tops, topsMap -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMostlyNoElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements) Creates a MostlyNoElementQualifierHierarchy from the given classes. -
Method Summary
Modifier and TypeMethodDescriptionfinal @Nullable AnnotationMirrorReturns the greatest lower bound for the qualifiers qualifier1 and qualifier2.protected abstract AnnotationMirrorgreatestLowerBoundWithElements(AnnotationMirror a1, QualifierKind qualifierKind1, AnnotationMirror a2, QualifierKind qualifierKind2, QualifierKind glbKind) Returns the greatest lower bound ofa1anda2in cases where the glb ofqualifierKind1andqualifierKind2is a qualifier kind that has elements.final booleanisSubtype(AnnotationMirror subAnno, AnnotationMirror superAnno) Tests whethersubQualifieris equal to or a sub-qualifier ofsuperQualifier, according to the type qualifier hierarchy.protected abstract booleanisSubtypeWithElements(AnnotationMirror subAnno, QualifierKind subKind, AnnotationMirror superAnno, QualifierKind superKind) Returns true ifsubAnnois a subtype ofsuperAnno.final @Nullable AnnotationMirrorReturns the least upper bound (LUB) of the qualifiersqualifier1andqualifier2.protected abstract AnnotationMirrorleastUpperBoundWithElements(AnnotationMirror a1, QualifierKind qualifierKind1, AnnotationMirror a2, QualifierKind qualifierKind2, QualifierKind lubKind) Returns the least upper bound ofa1anda2in cases where the lub ofqualifierKind1andqualifierKind2is a qualifier kind that has elements.Methods inherited from class org.checkerframework.framework.type.ElementQualifierHierarchy
createBottomsMap, createElementlessQualifierMap, createQualifierKindHierarchy, createTopsMap, findAnnotationInHierarchy, findAnnotationInSameHierarchy, getBottomAnnotation, getBottomAnnotations, getPolymorphicAnnotation, getQualifierKind, getQualifierKind, getTopAnnotation, getTopAnnotations, isPolymorphicQualifier, isValidMethods 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, leastUpperBounds, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBound
-
Constructor Details
-
MostlyNoElementQualifierHierarchy
protected MostlyNoElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements) Creates a MostlyNoElementQualifierHierarchy from the given classes.- Parameters:
qualifierClasses- classes of annotations that are the qualifiers for this hierarchyelements- element utils
-
-
Method Details
-
isSubtype
Description copied from interface:QualifierHierarchyTests whethersubQualifieris equal to or a sub-qualifier ofsuperQualifier, according to the type qualifier hierarchy.- Parameters:
subAnno- possible subqualifiersuperAnno- possible superqualifier- Returns:
- true iff
subQualifieris a subqualifier of, or equal to,superQualifier
-
isSubtypeWithElements
protected abstract boolean isSubtypeWithElements(AnnotationMirror subAnno, QualifierKind subKind, AnnotationMirror superAnno, QualifierKind superKind) Returns true ifsubAnnois a subtype ofsuperAnno. BothsubAnnoandsuperAnnoare annotations with elements.subKindis a sub qualifier kind ofsuperKind.- Parameters:
subAnno- possible subtype annotation; has elementssubKind- the QualifierKind ofsubAnnosuperAnno- possible super annotation; has elementssuperKind- the QualifierKind ofsuperAnno- Returns:
- true if
subAnnois a subtype ofsuperAnno
-
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
- 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
-
leastUpperBoundWithElements
protected abstract AnnotationMirror leastUpperBoundWithElements(AnnotationMirror a1, QualifierKind qualifierKind1, AnnotationMirror a2, QualifierKind qualifierKind2, QualifierKind lubKind) Returns the least upper bound ofa1anda2in cases where the lub ofqualifierKind1andqualifierKind2is a qualifier kind that has elements. If the lub ofqualifierKind1andqualifierKind2does not have elements, thenleastUpperBound(AnnotationMirror, AnnotationMirror)returns the correctAnnotationMirrorwithout calling this method.- Parameters:
a1- first annotationqualifierKind1- QualifierKind fora1a2- second annotationqualifierKind2- QualifierKind fora2lubKind- the kind of the lub ofqualifierKind1andqualifierKind2- Returns:
- the least upper bound of
a1anda2
-
greatestLowerBound
public final @Nullable AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2) 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.- 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
-
greatestLowerBoundWithElements
protected abstract AnnotationMirror greatestLowerBoundWithElements(AnnotationMirror a1, QualifierKind qualifierKind1, AnnotationMirror a2, QualifierKind qualifierKind2, QualifierKind glbKind) Returns the greatest lower bound ofa1anda2in cases where the glb ofqualifierKind1andqualifierKind2is a qualifier kind that has elements. If the glb ofqualifierKind1andqualifierKind2does not have elements, thengreatestLowerBound(AnnotationMirror, AnnotationMirror)returns the correctAnnotationMirrorwithout calling this method.- Parameters:
a1- first annotationqualifierKind1- QualifierKind fora1a2- second annotationqualifierKind2- QualifierKind fora2- Returns:
- the greatest lower bound between
a1anda2
-