Class NoElementQualifierHierarchy
- Direct Known Subclasses:
AliasingAnnotatedTypeFactory.AliasingQualifierHierarchy
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.Fields inherited from class org.checkerframework.framework.type.QualifierHierarchy
atypeFactory
-
Constructor Summary
ConstructorDescriptionNoElementQualifierHierarchy
(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements, GenericAnnotatedTypeFactory<?, ?, ?, ?> atypeFactory) 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.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.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
isSubtypeQualifiers
(AnnotationMirror subAnno, AnnotationMirror superAnno) Tests whethersubQualifier
is equal to or a sub-qualifier ofsuperQualifier
, according to the type qualifier hierarchy, ignoring Java basetypes.Returns the least upper bound (LUB) of the qualifiersqualifier1
andqualifier2
.Methods inherited from class org.checkerframework.framework.type.QualifierHierarchy
assertSameSize, assertSameSize, canHaveEmptyAnnotationSet, getWidth, greatestLowerBoundQualifiersOnly, greatestLowerBoundShallow, greatestLowerBoundsQualifiersOnly, greatestLowerBoundsQualifiersOnly, greatestLowerBoundsShallow, isSubtypeQualifiersOnly, isSubtypeQualifiersOnly, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, isTop, isValid, leastUpperBoundQualifiersOnly, leastUpperBoundShallow, leastUpperBoundsQualifiersOnly, leastUpperBoundsQualifiersOnly, leastUpperBoundsShallow, 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, GenericAnnotatedTypeFactory<?, ?, ?, ?> atypeFactory) Creates a NoElementQualifierHierarchy from the given classes.- Parameters:
qualifierClasses
- classes of annotations that are the qualifierselements
- element utilsatypeFactory
- the associated type factory
-
-
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 class: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.- Overrides:
findAnnotationInSameHierarchy
in classQualifierHierarchy
- Parameters:
annos
- the 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 class:QualifierHierarchy
Returns the annotation inqualifiers
that is in the hierarchy for whichtop
is top.- Overrides:
findAnnotationInHierarchy
in classQualifierHierarchy
- Parameters:
annos
- the 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 class: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 classQualifierHierarchy
- Returns:
- the top (ultimate super) type qualifiers in the type system
-
getTopAnnotation
Description copied from class: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 classQualifierHierarchy
- 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 class:QualifierHierarchy
Returns the bottom type qualifiers in the hierarchy. The size of this set is equal toQualifierHierarchy.getWidth()
.- Specified by:
getBottomAnnotations
in classQualifierHierarchy
- Returns:
- the bottom type qualifiers in the hierarchy
-
getBottomAnnotation
Description copied from class: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 classQualifierHierarchy
- 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 class:QualifierHierarchy
Returns the polymorphic qualifier for the hierarchy containingqualifier
, ornull
if there is no polymorphic qualifier in that hierarchy.- Specified by:
getPolymorphicAnnotation
in classQualifierHierarchy
- 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 class:QualifierHierarchy
Returnstrue
if the qualifier is a polymorphic qualifier; otherwise, returnsfalse
.- Specified by:
isPolymorphicQualifier
in classQualifierHierarchy
- Parameters:
qualifier
- qualifier- Returns:
true
if the qualifier is a polymorphic qualifier; otherwise, returnsfalse
.
-
isSubtypeQualifiers
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
-
leastUpperBoundQualifiers
public @Nullable AnnotationMirror leastUpperBoundQualifiers(AnnotationMirror a1, 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
-
greatestLowerBoundQualifiers
public @Nullable AnnotationMirror greatestLowerBoundQualifiers(AnnotationMirror a1, 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
-