@AnnotatedFor(value="nullness") public interface QualifierHierarchy
getWidth()
gives the number of hierarchies
that this object represents. Each hierarchy has its own top and bottom, and subtyping
relationships exist only within each hierarchy.
Note the distinction in terminology between a qualifier hierarchy, which has one top and one
bottom, and a QualifierHierarchy
, which represents multiple qualifier hierarchies.
All type annotations need to be type qualifiers recognized within this hierarchy.
This assumes that every annotated type in a program is annotated with exactly one qualifier from each hierarchy.
Modifier and Type | Method and Description |
---|---|
static void |
assertSameSize(Collection<?> c1,
Collection<?> c2)
Throws an exception if the given collections do not have the same size.
|
static void |
assertSameSize(Collection<?> c1,
Collection<?> c2,
Collection<?> result)
Throws an exception if the result does not have the same size as the inputs (which are
assumed to have the same size as one another).
|
static boolean |
canHaveEmptyAnnotationSet(AnnotatedTypeMirror type)
Returns true if and only if
AnnotatedTypeMirror.getAnnotations() can return a set
with fewer qualifiers than the width of the QualifierHierarchy. |
default @Nullable AnnotationMirror |
findAnnotationInHierarchy(Collection<? extends AnnotationMirror> qualifiers,
AnnotationMirror top)
Returns the annotation in
qualifiers that is in the hierarchy for which top
is top. |
default @Nullable AnnotationMirror |
findAnnotationInSameHierarchy(Collection<? extends AnnotationMirror> qualifiers,
AnnotationMirror qualifier)
Returns the annotation in
qualifiers that is in the same hierarchy as qualifier . |
AnnotationMirror |
getBottomAnnotation(AnnotationMirror qualifier)
Return the bottom for the given qualifier, that is, the qualifier that is a subtype of
qualifier but no further subtypes exist. |
Set<? extends AnnotationMirror> |
getBottomAnnotations()
Returns the bottom type qualifiers in the hierarchy.
|
@Nullable AnnotationMirror |
getPolymorphicAnnotation(AnnotationMirror qualifier)
Returns the polymorphic qualifier for the hierarchy containing
qualifier , or null if there is no polymorphic qualifier in that hierarchy. |
AnnotationMirror |
getTopAnnotation(AnnotationMirror qualifier)
Return the top qualifier for the given qualifier, that is, the qualifier that is a supertype
of
qualifier but no further supertypes exist. |
Set<? extends AnnotationMirror> |
getTopAnnotations()
Returns the top (ultimate super) type qualifiers in the type system.
|
default int |
getWidth()
Returns the width of this hierarchy, i.e.
|
default @Nullable AnnotationMirror |
greatestLowerBound(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
AnnotationMirror a1,
AnnotationMirror a2)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the relationship between "no qualifier" and a qualifier
|
@Nullable AnnotationMirror |
greatestLowerBound(AnnotationMirror qualifier1,
AnnotationMirror qualifier2)
Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.
|
default Set<? extends AnnotationMirror> |
greatestLowerBounds(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
Collection<? extends AnnotationMirror> annos1,
Collection<AnnotationMirror> annos2)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the relationship between "no qualifier" and a qualifier
|
default Set<? extends AnnotationMirror> |
greatestLowerBounds(Collection<? extends AnnotationMirror> qualifiers1,
Collection<? extends AnnotationMirror> qualifiers2)
Returns the greatest lower bound of the two sets of qualifiers.
|
default Set<? extends AnnotationMirror> |
greatestLowerBoundsTypeVariable(Collection<? extends AnnotationMirror> annos1,
Collection<? extends AnnotationMirror> annos2)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the relationship between "no qualifier" and a qualifier
|
default @Nullable AnnotationMirror |
greatestLowerBoundTypeVariable(AnnotationMirror a1,
AnnotationMirror a2)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the relationship between "no qualifier" and a qualifier
|
boolean |
isPolymorphicQualifier(AnnotationMirror qualifier)
Returns
true if the qualifier is a polymorphic qualifier; otherwise, returns false . |
default boolean |
isSubtype(AnnotatedTypeMirror subType,
AnnotatedTypeMirror superType,
AnnotationMirror subQualifier,
AnnotationMirror superQualifier)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the subtype relationship between "no qualifier" and a qualifier. Use
TypeHierarchy.isSubtype(AnnotatedTypeMirror, AnnotatedTypeMirror) . |
default boolean |
isSubtype(AnnotatedTypeMirror subType,
AnnotatedTypeMirror superType,
Collection<? extends AnnotationMirror> subs,
Collection<AnnotationMirror> supers)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the subtype relationship between "no qualifier" and a qualifier. Use
TypeHierarchy.isSubtype(AnnotatedTypeMirror, AnnotatedTypeMirror) . |
boolean |
isSubtype(AnnotationMirror subQualifier,
AnnotationMirror superQualifier)
Tests whether
subQualifier is equal to or a sub-qualifier of superQualifier ,
according to the type qualifier hierarchy. |
default boolean |
isSubtype(Collection<? extends AnnotationMirror> subQualifiers,
Collection<? extends AnnotationMirror> superQualifiers)
Tests whether all qualifiers in
subQualifiers are a subqualifier or equal to the
qualifier in the same hierarchy in superQualifiers . |
default boolean |
isSubtypeTypeVariable(@Nullable AnnotationMirror subQualifier,
@Nullable AnnotationMirror superQualifier)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the subtype relationship between "no qualifier" and a qualifier. Use
TypeHierarchy.isSubtype(AnnotatedTypeMirror, AnnotatedTypeMirror) . |
default boolean |
isSubtypeTypeVariable(Collection<? extends AnnotationMirror> subAnnos,
Collection<? extends AnnotationMirror> superAnnos)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the subtype relationship between "no qualifier" and a qualifier. Use
TypeHierarchy.isSubtype(AnnotatedTypeMirror, AnnotatedTypeMirror) . |
default boolean |
isValid()
Determine whether this is valid.
|
default @Nullable AnnotationMirror |
leastUpperBound(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
AnnotationMirror a1,
AnnotationMirror a2)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the relationship between "no qualifier" and a qualifier. Use
AnnotatedTypes.leastUpperBound(AnnotatedTypeFactory,
AnnotatedTypeMirror, AnnotatedTypeMirror) . |
@Nullable AnnotationMirror |
leastUpperBound(AnnotationMirror qualifier1,
AnnotationMirror qualifier2)
Returns the least upper bound (LUB) of the qualifiers
qualifier1 and qualifier2 . |
default Set<? extends AnnotationMirror> |
leastUpperBounds(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
Collection<? extends AnnotationMirror> annos1,
Collection<AnnotationMirror> annos2)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the relationship between "no qualifier" and a qualifier. Use
AnnotatedTypes.leastUpperBound(AnnotatedTypeFactory,
AnnotatedTypeMirror, AnnotatedTypeMirror) . |
default Set<? extends AnnotationMirror> |
leastUpperBounds(Collection<? extends AnnotationMirror> qualifiers1,
Collection<? extends AnnotationMirror> qualifiers2)
Returns the least upper bound of the two sets of qualifiers.
|
default Set<? extends AnnotationMirror> |
leastUpperBoundsTypeVariable(Collection<? extends AnnotationMirror> annos1,
Collection<? extends AnnotationMirror> annos2)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the relationship between "no qualifier" and a qualifier. Use
AnnotatedTypes.leastUpperBound(AnnotatedTypeFactory,
AnnotatedTypeMirror, AnnotatedTypeMirror) . |
default @Nullable AnnotationMirror |
leastUpperBoundTypeVariable(AnnotationMirror a1,
AnnotationMirror a2)
Deprecated.
Without the bounds of the type variable, it is not possible to correctly compute
the relationship between "no qualifier" and a qualifier. Use
AnnotatedTypes.leastUpperBound(AnnotatedTypeFactory,
AnnotatedTypeMirror, AnnotatedTypeMirror) . |
default int |
numberOfIterationsBeforeWidening()
Returns the number of iterations dataflow should perform before
widenedUpperBound(AnnotationMirror, AnnotationMirror) is called or -1 if it should never be
called. |
default <T> boolean |
updateMappingToMutableSet(Map<T,Set<AnnotationMirror>> map,
T key,
AnnotationMirror qualifier)
Update a mapping from
key to a set of AnnotationMirrors. |
default AnnotationMirror |
widenedUpperBound(AnnotationMirror newQualifier,
AnnotationMirror previousQualifier)
If the qualifier hierarchy has an infinite ascending chain, then the dataflow analysis might
never reach a fixed point.
|
default boolean isValid()
default int getWidth()
Set<? extends AnnotationMirror> getTopAnnotations()
getWidth()
.AnnotationMirror getTopAnnotation(AnnotationMirror qualifier)
qualifier
but no further supertypes exist.qualifier
- any qualifier from one of the qualifier hierarchies represented by thisqualifier
's hierarchySet<? extends AnnotationMirror> getBottomAnnotations()
getWidth()
.AnnotationMirror getBottomAnnotation(AnnotationMirror qualifier)
qualifier
but no further subtypes exist.qualifier
- any qualifier from one of the qualifier hierarchies represented by thisqualifier
's hierarchy@Nullable AnnotationMirror getPolymorphicAnnotation(AnnotationMirror qualifier)
qualifier
, or null
if there is no polymorphic qualifier in that hierarchy.qualifier
- any qualifier from one of the qualifier hierarchies represented by thisqualifier
, or null
if there is no polymorphic qualifier in that hierarchyboolean isPolymorphicQualifier(AnnotationMirror qualifier)
true
if the qualifier is a polymorphic qualifier; otherwise, returns false
.qualifier
- qualifiertrue
if the qualifier is a polymorphic qualifier; otherwise, returns false
.boolean isSubtype(AnnotationMirror subQualifier, AnnotationMirror superQualifier)
subQualifier
is equal to or a sub-qualifier of superQualifier
,
according to the type qualifier hierarchy.subQualifier
- possible subqualifier of superQualifier
superQualifier
- possible superqualifier of subQualifier
subQualifier
is a subqualifier of, or equal to, superQualifier
default boolean isSubtype(Collection<? extends AnnotationMirror> subQualifiers, Collection<? extends AnnotationMirror> superQualifiers)
subQualifiers
are a subqualifier or equal to the
qualifier in the same hierarchy in superQualifiers
.subQualifiers
- set of qualifiers; exactly one per hierarchysuperQualifiers
- set of qualifiers; exactly one per hierarchysubQualifiers
are a subqualifier or equal to the
qualifier in the same hierarchy in superQualifiers
@Nullable AnnotationMirror leastUpperBound(AnnotationMirror qualifier1, AnnotationMirror qualifier2)
qualifier1
and qualifier2
. Returns null
if the qualifiers are not from the same qualifier
hierarchy.
Examples:
qualifier1
- the first qualifier; may not be in the same hierarchy as qualifier2
qualifier2
- the second qualifier; may not be in the same hierarchy as qualifier1
null
if the qualifiers are from
different hierarchiesdefault Set<? extends AnnotationMirror> leastUpperBounds(Collection<? extends AnnotationMirror> qualifiers1, Collection<? extends AnnotationMirror> qualifiers2)
qualifiers1
- set of qualifiers; exactly one per hierarchyqualifiers2
- set of qualifiers; exactly one per hierarchydefault int numberOfIterationsBeforeWidening()
widenedUpperBound(AnnotationMirror, AnnotationMirror)
is called or -1 if it should never be
called.widenedUpperBound(AnnotationMirror, AnnotationMirror)
is called or -1 if it should
never be called.default AnnotationMirror widenedUpperBound(AnnotationMirror newQualifier, AnnotationMirror previousQualifier)
numberOfIterationsBeforeWidening()
to
return a positive number.
newQualifier
is newest qualifier dataflow computed for some expression and previousQualifier
is the qualifier dataflow computed on the last iteration.
If the qualifier hierarchy has no infinite ascending chain, returns the least upper bound of the two annotations.
newQualifier
- new qualifier dataflow computed for some expression; must be in the same
hierarchy as previousQualifier
previousQualifier
- the previous qualifier dataflow computed on the last iteration; must
be in the same hierarchy as previousQualifier
@Nullable AnnotationMirror greatestLowerBound(AnnotationMirror qualifier1, AnnotationMirror qualifier2)
qualifier1
- first qualifierqualifier2
- second qualifierdefault Set<? extends AnnotationMirror> greatestLowerBounds(Collection<? extends AnnotationMirror> qualifiers1, Collection<? extends AnnotationMirror> qualifiers2)
qualifiers1
- set of qualifiers; exactly one per hierarchyqualifiers2
- set of qualifiers; exactly one per hierarchystatic boolean canHaveEmptyAnnotationSet(AnnotatedTypeMirror type)
AnnotatedTypeMirror.getAnnotations()
can return a set
with fewer qualifiers than the width of the QualifierHierarchy.type
- the type to testAnnotatedTypeMirror.getAnnotations()
can return a set
with fewer qualifiers than the width of the QualifierHierarchydefault @Nullable AnnotationMirror findAnnotationInSameHierarchy(Collection<? extends AnnotationMirror> qualifiers, AnnotationMirror qualifier)
qualifiers
that is in the same hierarchy as qualifier
.
The default implementation calls getTopAnnotation(AnnotationMirror)
and then
calls findAnnotationInHierarchy(Collection, AnnotationMirror)
. So, if qualifier
is a top qualifier, then call findAnnotationInHierarchy(Collection,
AnnotationMirror)
directly is faster.
qualifiers
- set of annotations to searchqualifier
- annotation that is in the same hierarchy as the returned annotationdefault @Nullable AnnotationMirror findAnnotationInHierarchy(Collection<? extends AnnotationMirror> qualifiers, AnnotationMirror top)
qualifiers
that is in the hierarchy for which top
is top.qualifiers
- set of annotations to searchtop
- the top annotation in the hierarchy to which the returned annotation belongsdefault <T> boolean updateMappingToMutableSet(Map<T,Set<AnnotationMirror>> map, T key, AnnotationMirror qualifier)
key
to a set of AnnotationMirrors. If key
is not
already in the map, then put it in the map with a value of a new set containing qualifier
. If the map contains key
, then add qualifier
to the set to which
key
maps. If that set contains a qualifier in the same hierarchy as qualifier
, then don't add it and return false.T
- type of the map's keysmap
- the mapping to modifykey
- the key to update or addqualifier
- the value to update or addstatic void assertSameSize(Collection<?> c1, Collection<?> c2)
c1
- the first collectionc2
- the second collectionstatic void assertSameSize(Collection<?> c1, Collection<?> c2, Collection<?> result)
c1
- the first collectionc2
- the second collectionresult
- the result collection@Deprecated default boolean isSubtypeTypeVariable(@Nullable AnnotationMirror subQualifier, @Nullable AnnotationMirror superQualifier)
TypeHierarchy.isSubtype(AnnotatedTypeMirror, AnnotatedTypeMirror)
.subQualifier
is a sub-qualifier of, or equal to, superQualifier
, according to the type qualifier hierarchy.
This method works even if the underlying Java type is a type variable. In that case, a 'null' AnnotationMirror is a legal argument that represents no annotation.
subQualifier
- a qualifier that might be a subtypesuperQualifier
- a qualifier that might be a subtypesubQualifier
is a subqualifier of, or equal to, superQualifier
@Deprecated default boolean isSubtype(AnnotatedTypeMirror subType, AnnotatedTypeMirror superType, AnnotationMirror subQualifier, AnnotationMirror superQualifier)
TypeHierarchy.isSubtype(AnnotatedTypeMirror, AnnotatedTypeMirror)
.subQualifier
is a sub-qualifier of, or equal to, superQualifier
, according to the type qualifier hierarchy. This checks only the qualifiers,
not the Java type.
This method takes an annotated type to decide if the type variable version of the method should be invoked, or if the normal version is sufficient (which provides more strict checks).
subType
- used to decide whether to call isSubtypeTypeVariablesuperType
- used to decide whether to call isSubtypeTypeVariablesubQualifier
- the type qualifier that might be a subtypesuperQualifier
- the type qualifier that might be a supertypesubQualifier
is a subqualifier of, or equal to, superQualifier
@Deprecated default boolean isSubtype(AnnotatedTypeMirror subType, AnnotatedTypeMirror superType, Collection<? extends AnnotationMirror> subs, Collection<AnnotationMirror> supers)
TypeHierarchy.isSubtype(AnnotatedTypeMirror, AnnotatedTypeMirror)
.supers
that is a superqualifier of, or equal
to, some annotation in subs
. supers
and subs
contain only the
annotations, not the Java type.
This method takes an annotated type to decide if the type variable version of the method should be invoked, or if the normal version is sufficient (which provides more strict checks).
subType
- used to decide whether to call isSubtypeTypeVariablesuperType
- used to decide whether to call isSubtypeTypeVariablesubs
- the type qualifiers that might be a subtypesupers
- the type qualifiers that might be a supertypesupers
is a supertype of, or equal to, one in
subs
@Deprecated default boolean isSubtypeTypeVariable(Collection<? extends AnnotationMirror> subAnnos, Collection<? extends AnnotationMirror> superAnnos)
TypeHierarchy.isSubtype(AnnotatedTypeMirror, AnnotatedTypeMirror)
.This method works even if the underlying Java type is a type variable. In that case, the empty set is a legal argument that represents no annotation.
subAnnos
- qualifierssuperAnnos
- qualifiers@Deprecated default @Nullable AnnotationMirror leastUpperBoundTypeVariable(AnnotationMirror a1, AnnotationMirror a2)
AnnotatedTypes.leastUpperBound(AnnotatedTypeFactory,
AnnotatedTypeMirror, AnnotatedTypeMirror)
.Examples:
This method works even if the underlying Java type is a type variable. In that case, a 'null' AnnotationMirror is a legal argument that represents no annotation.
a1
- anno1a2
- anno2@Deprecated default @Nullable AnnotationMirror leastUpperBound(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, AnnotationMirror a1, AnnotationMirror a2)
AnnotatedTypes.leastUpperBound(AnnotatedTypeFactory,
AnnotatedTypeMirror, AnnotatedTypeMirror)
.Examples:
This method takes an annotated type to decide if the type variable version of the method should be invoked, or if the normal version is sufficient (which provides more strict checks).
type1
- type 1type2
- type 2a1
- annotationa2
- annotation@Deprecated default Set<? extends AnnotationMirror> leastUpperBoundsTypeVariable(Collection<? extends AnnotationMirror> annos1, Collection<? extends AnnotationMirror> annos2)
AnnotatedTypes.leastUpperBound(AnnotatedTypeFactory,
AnnotatedTypeMirror, AnnotatedTypeMirror)
.This is necessary for determining the type of a conditional expression (?:
), where
the type of the expression is the least upper bound of the true and false clauses.
This method works even if the underlying Java type is a type variable. In that case, the empty set is a legal argument that represents no annotation.
annos1
- qualifiersannos2
- qualifiers@Deprecated default Set<? extends AnnotationMirror> leastUpperBounds(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, Collection<? extends AnnotationMirror> annos1, Collection<AnnotationMirror> annos2)
AnnotatedTypes.leastUpperBound(AnnotatedTypeFactory,
AnnotatedTypeMirror, AnnotatedTypeMirror)
.This is necessary for determining the type of a conditional expression (?:
), where
the type of the expression is the least upper bound of the true and false clauses.
This method takes an annotated type to decide if the type variable version of the method should be invoked, or if the normal version is sufficient (which provides more strict checks).
type1
- annotated typetype2
- annotated typeannos1
- qualifiersannos2
- qualifiers@Deprecated default @Nullable AnnotationMirror greatestLowerBoundTypeVariable(AnnotationMirror a1, AnnotationMirror a2)
This method works even if the underlying Java type is a type variable. In that case, a 'null' AnnotationMirror is a legal argument that represents no annotation.
a1
- first annotationa2
- second annotation@Deprecated default Set<? extends AnnotationMirror> greatestLowerBoundsTypeVariable(Collection<? extends AnnotationMirror> annos1, Collection<? extends AnnotationMirror> annos2)
This method works even if the underlying Java type is a type variable. In that case, the empty set is a legal argument that represents no annotation.
annos1
- first collection of qualifiersannos2
- second collection of qualifiers@Deprecated default @Nullable AnnotationMirror greatestLowerBound(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, AnnotationMirror a1, AnnotationMirror a2)
This method takes an annotated type to decide if the type variable version of the method should be invoked, or if the normal version is sufficient (which provides more strict checks).
type1
- annotated typetype2
- annotated typea1
- first annotationa2
- second annotation@Deprecated default Set<? extends AnnotationMirror> greatestLowerBounds(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, Collection<? extends AnnotationMirror> annos1, Collection<AnnotationMirror> annos2)
This method takes an annotated type to decide if the type variable version of the method should be invoked, or if the normal version is sufficient (which provides more strict checks).
type1
- annotated typetype2
- annotated typeannos1
- first collection of qualifiersannos2
- second collection of qualifiers