Class MostlyNoElementQualifierHierarchy
- java.lang.Object
-
- org.checkerframework.framework.type.QualifierHierarchy
-
- org.checkerframework.framework.type.ElementQualifierHierarchy
-
- org.checkerframework.framework.type.MostlyNoElementQualifierHierarchy
-
- Direct Known Subclasses:
FenumAnnotatedTypeFactory.FenumQualifierHierarchy
,InitializationParentAnnotatedTypeFactory.InitializationQualifierHierarchy
,SubtypeIsSubsetQualifierHierarchy
,SubtypeIsSupersetQualifierHierarchy
,UnitsAnnotatedTypeFactory.UnitsQualifierHierarchy
@AnnotatedFor("nullness") public abstract class MostlyNoElementQualifierHierarchy extends ElementQualifierHierarchy
AQualifierHierarchy
where qualifiers may be represented by annotations with elements, but most of the qualifiers do not have elements. In contrast toElementQualifierHierarchy
, this class partially implementsQualifierHierarchy.isSubtypeShallow(AnnotationMirror, TypeMirror, AnnotationMirror, TypeMirror)
,QualifierHierarchy.leastUpperBoundShallow(AnnotationMirror, TypeMirror, AnnotationMirror, TypeMirror)
, andQualifierHierarchy.greatestLowerBoundShallow(AnnotationMirror, TypeMirror, AnnotationMirror, TypeMirror)
and calls *WithElements when the result cannot be computed from the meta-annotationsSubtypeOf
.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 overrideElementQualifierHierarchy.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
-
Fields inherited from class org.checkerframework.framework.type.QualifierHierarchy
atypeFactory
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MostlyNoElementQualifierHierarchy(java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> qualifierClasses, javax.lang.model.util.Elements elements, GenericAnnotatedTypeFactory<?,?,?,?> atypeFactory)
Creates a MostlyNoElementQualifierHierarchy from the given classes.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description @Nullable javax.lang.model.element.AnnotationMirror
greatestLowerBoundQualifiers(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.protected abstract javax.lang.model.element.AnnotationMirror
greatestLowerBoundWithElements(javax.lang.model.element.AnnotationMirror a1, QualifierKind qualifierKind1, javax.lang.model.element.AnnotationMirror a2, QualifierKind qualifierKind2, QualifierKind glbKind)
Returns the greatest lower bound ofa1
anda2
in cases where the glb ofqualifierKind1
andqualifierKind2
is a qualifier kind that has elements.boolean
isSubtypeQualifiers(javax.lang.model.element.AnnotationMirror subAnno, javax.lang.model.element.AnnotationMirror superAnno)
Tests whethersubQualifier
is equal to or a sub-qualifier ofsuperQualifier
, according to the type qualifier hierarchy, ignoring Java basetypes.protected abstract boolean
isSubtypeWithElements(javax.lang.model.element.AnnotationMirror subAnno, QualifierKind subKind, javax.lang.model.element.AnnotationMirror superAnno, QualifierKind superKind)
Returns true ifsubAnno
is a subtype ofsuperAnno
.@Nullable javax.lang.model.element.AnnotationMirror
leastUpperBoundQualifiers(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
Returns the least upper bound (LUB) of the qualifiersqualifier1
andqualifier2
.protected abstract javax.lang.model.element.AnnotationMirror
leastUpperBoundWithElements(javax.lang.model.element.AnnotationMirror a1, QualifierKind qualifierKind1, javax.lang.model.element.AnnotationMirror a2, QualifierKind qualifierKind2, QualifierKind lubKind)
Returns the least upper bound ofa1
anda2
in cases where the lub ofqualifierKind1
andqualifierKind2
is 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, isValid
-
Methods inherited from class org.checkerframework.framework.type.QualifierHierarchy
assertSameSize, assertSameSize, canHaveEmptyAnnotationSet, getWidth, greatestLowerBoundQualifiersOnly, greatestLowerBoundShallow, greatestLowerBoundsShallow, isSubtypeQualifiersOnly, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, leastUpperBoundQualifiersOnly, leastUpperBoundShallow, leastUpperBoundsShallow, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBound
-
-
-
-
Constructor Detail
-
MostlyNoElementQualifierHierarchy
protected MostlyNoElementQualifierHierarchy(java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> qualifierClasses, javax.lang.model.util.Elements elements, GenericAnnotatedTypeFactory<?,?,?,?> atypeFactory)
Creates a MostlyNoElementQualifierHierarchy from the given classes.- Parameters:
qualifierClasses
- classes of annotations that are the qualifiers for this hierarchyelements
- element utilsatypeFactory
- the associated type factory
-
-
Method Detail
-
isSubtypeQualifiers
public final boolean isSubtypeQualifiers(javax.lang.model.element.AnnotationMirror subAnno, javax.lang.model.element.AnnotationMirror superAnno)
Description copied from class:QualifierHierarchy
Tests whethersubQualifier
is equal to or a sub-qualifier ofsuperQualifier
, according to the type qualifier hierarchy, ignoring Java basetypes.Clients should generally call
QualifierHierarchy.isSubtypeShallow(javax.lang.model.element.AnnotationMirror, javax.lang.model.type.TypeMirror, javax.lang.model.element.AnnotationMirror, javax.lang.model.type.TypeMirror)
. However, subtypes should generally override this method (if needed).This method behaves the same as
QualifierHierarchy.isSubtypeQualifiersOnly(AnnotationMirror, AnnotationMirror)
, which calls this method. This method is for clients inside the framework, and it hasprotected
access to prevent use by clients outside the framework. This makes it easy to find places where code outside the framework is ignoring Java basetypes -- at calls toQualifierHierarchy.isSubtypeQualifiersOnly(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror)
.- Specified by:
isSubtypeQualifiers
in classQualifierHierarchy
- Parameters:
subAnno
- possible subqualifiersuperAnno
- possible superqualifier- Returns:
- true iff
subQualifier
is a subqualifier of, or equal to,superQualifier
-
isSubtypeWithElements
protected abstract boolean isSubtypeWithElements(javax.lang.model.element.AnnotationMirror subAnno, QualifierKind subKind, javax.lang.model.element.AnnotationMirror superAnno, QualifierKind superKind)
Returns true ifsubAnno
is a subtype ofsuperAnno
. BothsubAnno
andsuperAnno
are annotations with elements.subKind
is a sub qualifier kind ofsuperKind
.- Parameters:
subAnno
- possible subtype annotation; has elementssubKind
- the QualifierKind ofsubAnno
superAnno
- possible super annotation; has elementssuperKind
- the QualifierKind ofsuperAnno
- Returns:
- true if
subAnno
is a subtype ofsuperAnno
-
leastUpperBoundQualifiers
public final @Nullable javax.lang.model.element.AnnotationMirror leastUpperBoundQualifiers(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
Description copied from class:QualifierHierarchy
Returns the least upper bound (LUB) of the qualifiersqualifier1
andqualifier2
. Returnsnull
if the qualifiers are not from the same qualifier hierarchy. Ignores Java basetypes.Examples:
- For NonNull, leastUpperBound('Nullable', 'NonNull') ⇒ Nullable
- Specified by:
leastUpperBoundQualifiers
in classQualifierHierarchy
- 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
-
leastUpperBoundWithElements
protected abstract javax.lang.model.element.AnnotationMirror leastUpperBoundWithElements(javax.lang.model.element.AnnotationMirror a1, QualifierKind qualifierKind1, javax.lang.model.element.AnnotationMirror a2, QualifierKind qualifierKind2, QualifierKind lubKind)
Returns the least upper bound ofa1
anda2
in cases where the lub ofqualifierKind1
andqualifierKind2
is a qualifier kind that has elements. If the lub ofqualifierKind1
andqualifierKind2
does not have elements, thenQualifierHierarchy.leastUpperBoundShallow(AnnotationMirror, TypeMirror, AnnotationMirror, TypeMirror)
returns the correctAnnotationMirror
without calling this method.- Parameters:
a1
- first annotationqualifierKind1
- QualifierKind fora1
a2
- second annotationqualifierKind2
- QualifierKind fora2
lubKind
- the kind of the lub ofqualifierKind1
andqualifierKind2
- Returns:
- the least upper bound of
a1
anda2
-
greatestLowerBoundQualifiers
public final @Nullable javax.lang.model.element.AnnotationMirror greatestLowerBoundQualifiers(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
Description copied from class: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:
greatestLowerBoundQualifiers
in classQualifierHierarchy
- 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 javax.lang.model.element.AnnotationMirror greatestLowerBoundWithElements(javax.lang.model.element.AnnotationMirror a1, QualifierKind qualifierKind1, javax.lang.model.element.AnnotationMirror a2, QualifierKind qualifierKind2, QualifierKind glbKind)
Returns the greatest lower bound ofa1
anda2
in cases where the glb ofqualifierKind1
andqualifierKind2
is a qualifier kind that has elements. If the glb ofqualifierKind1
andqualifierKind2
does not have elements, thenQualifierHierarchy.greatestLowerBoundShallow(AnnotationMirror, TypeMirror, AnnotationMirror, TypeMirror)
returns the correctAnnotationMirror
without calling this method.- Parameters:
a1
- first annotationqualifierKind1
- QualifierKind fora1
a2
- second annotationqualifierKind2
- QualifierKind fora2
- Returns:
- the greatest lower bound between
a1
anda2
-
-