@AnnotatedFor(value="nullness") public abstract class MostlyNoElementQualifierHierarchy extends ElementQualifierHierarchy
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)
greatestLowerBoundWithElements(AnnotationMirror, QualifierKind, AnnotationMirror,
QualifierKind)
MostlyNoElementQualifierHierarchy uses a QualifierKindHierarchy
to model the
relationships between qualifiers. Subclasses can override ElementQualifierHierarchy.createQualifierKindHierarchy(Collection)
to return a subclass of QualifierKindHierarchy.
bottoms, bottomsMap, kindToElementlessQualifier, qualifierKindHierarchy, tops, topsMap
Modifier | Constructor and Description |
---|---|
protected |
MostlyNoElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses,
Elements elements)
Creates a MostlyNoElementQualifierHierarchy from the given classes.
|
Modifier and Type | Method and Description |
---|---|
@Nullable AnnotationMirror |
greatestLowerBound(AnnotationMirror a1,
AnnotationMirror a2)
Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.
|
protected abstract AnnotationMirror |
greatestLowerBoundWithElements(AnnotationMirror a1,
QualifierKind qualifierKind1,
AnnotationMirror a2,
QualifierKind qualifierKind2)
Returns the greatest lower bound of
a1 and a2 in cases where the glb of
qualifierKind1 and qualifierKind2 is a qualifier kind that has elements. |
boolean |
isSubtype(AnnotationMirror subAnno,
AnnotationMirror superAnno)
Tests whether
subQualifier is equal to or a sub-qualifier of superQualifier ,
according to the type qualifier hierarchy. |
protected abstract boolean |
isSubtypeWithElements(AnnotationMirror subAnno,
QualifierKind subKind,
AnnotationMirror superAnno,
QualifierKind superKind)
Returns true if
subAnno is a subtype of superAnno . |
@Nullable AnnotationMirror |
leastUpperBound(AnnotationMirror a1,
AnnotationMirror a2)
Returns the least upper bound (LUB) of the qualifiers
qualifier1 and qualifier2 . |
protected abstract AnnotationMirror |
leastUpperBoundWithElements(AnnotationMirror a1,
QualifierKind qualifierKind1,
AnnotationMirror a2,
QualifierKind qualifierKind2)
Returns the least upper bound of
a1 and a2 in cases where the lub of qualifierKind1 and qualifierKind2 is a qualifier kind that has elements. |
createBottomsMap, createElementlessQualifierMap, createQualifierKindHierarchy, createTopsMap, findAnnotationInHierarchy, findAnnotationInSameHierarchy, getBottomAnnotation, getBottomAnnotations, getPolymorphicAnnotation, getQualifierKind, getQualifierKind, getTopAnnotation, getTopAnnotations, isPolymorphicQualifier, isValid
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
assertSameSize, assertSameSize, canHaveEmptyAnnotationSet, getWidth, greatestLowerBound, greatestLowerBounds, greatestLowerBounds, greatestLowerBoundsTypeVariable, greatestLowerBoundTypeVariable, isSubtype, isSubtype, isSubtype, isSubtypeTypeVariable, isSubtypeTypeVariable, leastUpperBound, leastUpperBounds, leastUpperBounds, leastUpperBoundsTypeVariable, leastUpperBoundTypeVariable, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBound
protected MostlyNoElementQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements)
qualifierClasses
- classes of annotations that are the qualifiers for this hierarchyelements
- element utilspublic final boolean isSubtype(AnnotationMirror subAnno, AnnotationMirror superAnno)
QualifierHierarchy
subQualifier
is equal to or a sub-qualifier of superQualifier
,
according to the type qualifier hierarchy.subAnno
- possible subqualifier of superQualifier
superAnno
- possible superqualifier of subQualifier
subQualifier
is a subqualifier of, or equal to, superQualifier
protected abstract boolean isSubtypeWithElements(AnnotationMirror subAnno, QualifierKind subKind, AnnotationMirror superAnno, QualifierKind superKind)
subAnno
is a subtype of superAnno
. Both subAnno
and
superAnno
are annotations with elements. subKind
is a sub qualifier kind of
superKind
.subAnno
- possible subtype annotation; has elementssubKind
- QualifierKind of subAnno
superAnno
- possible super annotation; has elementssuperKind
- QualifierKind of superAnno
subAnno
is a subtype of superAnno
public final @Nullable AnnotationMirror leastUpperBound(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchy
qualifier1
and qualifier2
. Returns null
if the qualifiers are not from the same qualifier
hierarchy.
Examples:
a1
- the first qualifier; may not be in the same hierarchy as qualifier2
a2
- the second qualifier; may not be in the same hierarchy as qualifier1
null
if the qualifiers are from
different hierarchiesprotected abstract AnnotationMirror leastUpperBoundWithElements(AnnotationMirror a1, QualifierKind qualifierKind1, AnnotationMirror a2, QualifierKind qualifierKind2)
a1
and a2
in cases where the lub of qualifierKind1
and qualifierKind2
is a qualifier kind that has elements. If the lub
of qualifierKind1
and qualifierKind2
does not have elements, then leastUpperBound(AnnotationMirror, AnnotationMirror)
returns the correct AnnotationMirror
without calling this method.a1
- first annotationqualifierKind1
- QualifierKind for a1
a2
- second annotationqualifierKind2
- QualifierKind for a2
a1
and a2
public final @Nullable AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchy
a1
- first qualifiera2
- second qualifierprotected abstract AnnotationMirror greatestLowerBoundWithElements(AnnotationMirror a1, QualifierKind qualifierKind1, AnnotationMirror a2, QualifierKind qualifierKind2)
a1
and a2
in cases where the glb of
qualifierKind1
and qualifierKind2
is a qualifier kind that has elements. If
the glb of qualifierKind1
and qualifierKind2
does not have elements, then
greatestLowerBound(AnnotationMirror, AnnotationMirror)
returns the correct AnnotationMirror
without calling this method.a1
- first annotationqualifierKind1
- QualifierKind for a1
a2
- second annotationqualifierKind2
- QualifierKind for a2
a1
and a2