public abstract class QualifierHierarchy
extends java.lang.Object
All method parameter annotations need to be type qualifiers recognized within this hierarchy.
This assumes that any particular annotated type in a program is annotated with at least one qualifier from the hierarchy.
Constructor and Description |
---|
QualifierHierarchy() |
Modifier and Type | Method and Description |
---|---|
static boolean |
canHaveEmptyAnnotationSet(AnnotatedTypeMirror type)
Returns true if and only if the given type can have empty annotation sets (and thus the
*TypeVariable methods need to be used).
|
javax.lang.model.element.AnnotationMirror |
findAnnotationInHierarchy(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos,
javax.lang.model.element.AnnotationMirror top)
Returns the annotation in annos that is in the hierarchy for which annotationMirror is top.
|
javax.lang.model.element.AnnotationMirror |
findAnnotationInSameHierarchy(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos,
javax.lang.model.element.AnnotationMirror annotationMirror)
Returns the annotation in annos that is in the same hierarchy as annotationMirror.
|
javax.lang.model.element.AnnotationMirror |
findCorrespondingAnnotation(javax.lang.model.element.AnnotationMirror aliased,
java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> a)
Deprecated.
|
javax.lang.model.element.AnnotationMirror |
getAnnotationInHierarchy(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos,
javax.lang.model.element.AnnotationMirror annotationMirror)
Deprecated.
|
abstract javax.lang.model.element.AnnotationMirror |
getBottomAnnotation(javax.lang.model.element.AnnotationMirror start)
Return the bottom for the given qualifier, that is, the qualifier that is a subtype of start
but no further subtypes exist.
|
abstract java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
getBottomAnnotations() |
abstract javax.lang.model.element.AnnotationMirror |
getPolymorphicAnnotation(javax.lang.model.element.AnnotationMirror start) |
abstract javax.lang.model.element.AnnotationMirror |
getTopAnnotation(javax.lang.model.element.AnnotationMirror start)
Return the top qualifier for the given qualifier, that is, the qualifier that is a supertype
of start but no further supertypes exist.
|
abstract java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
getTopAnnotations() |
abstract java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
getTypeQualifiers()
Returns all type qualifiers in this type qualifier hierarchy.
|
int |
getWidth()
Returns the width of this hierarchy, i.e.
|
javax.lang.model.element.AnnotationMirror |
greatestLowerBound(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
javax.lang.model.element.AnnotationMirror a1,
javax.lang.model.element.AnnotationMirror a2)
Returns the greatest lower bound for the qualifiers a1 and a2.
|
abstract javax.lang.model.element.AnnotationMirror |
greatestLowerBound(javax.lang.model.element.AnnotationMirror a1,
javax.lang.model.element.AnnotationMirror a2)
Returns the greatest lower bound for the qualifiers a1 and a2.
|
java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
greatestLowerBounds(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1,
java.util.Collection<javax.lang.model.element.AnnotationMirror> annos2)
Returns the type qualifiers that are the greatest lower bound of the qualifiers in annos1 and
annos2.
|
java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
greatestLowerBounds(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1,
java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos2)
Returns the greatest lower bound of two types.
|
java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
greatestLowerBoundsTypeVariable(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1,
java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos2)
Returns the type qualifiers that are the greatest lower bound of the qualifiers in annos1 and
annos2.
|
abstract javax.lang.model.element.AnnotationMirror |
greatestLowerBoundTypeVariable(javax.lang.model.element.AnnotationMirror a1,
javax.lang.model.element.AnnotationMirror a2)
Returns the greatest lower bound for the qualifiers a1 and a2.
|
boolean |
isSubtype(AnnotatedTypeMirror subType,
AnnotatedTypeMirror superType,
javax.lang.model.element.AnnotationMirror subAnno,
javax.lang.model.element.AnnotationMirror superAnno)
Tests whether
subAnno is a sub-qualifier of superAnno , according to the type
qualifier hierarchy. |
boolean |
isSubtype(AnnotatedTypeMirror subType,
AnnotatedTypeMirror superType,
java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> subs,
java.util.Collection<javax.lang.model.element.AnnotationMirror> supers)
Tests whether there is any annotation in
supers that is a super qualifier of some
annotation in subs . |
abstract boolean |
isSubtype(javax.lang.model.element.AnnotationMirror rhs,
javax.lang.model.element.AnnotationMirror lhs)
Tests whether rhs is equal to or a sub-qualifier of lhs, according to the type qualifier
hierarchy.
|
abstract boolean |
isSubtype(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> rhs,
java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> lhs)
Tests whether there is any annotation in lhs that is a super qualifier of some annotation in
rhs.
|
abstract boolean |
isSubtypeTypeVariable(javax.lang.model.element.AnnotationMirror subAnno,
javax.lang.model.element.AnnotationMirror superAnno)
Tests whether
subAnno is a sub-qualifier of superAnno , according to the type
qualifier hierarchy. |
abstract boolean |
isSubtypeTypeVariable(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> subAnnos,
java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> superAnnos)
Tests whether there is any annotation in superAnnos that is a super qualifier of some
annotation in subAnnos.
|
boolean |
isValid()
Determine whether the instance is valid.
|
javax.lang.model.element.AnnotationMirror |
leastUpperBound(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
javax.lang.model.element.AnnotationMirror a1,
javax.lang.model.element.AnnotationMirror a2)
Returns the least upper bound for the qualifiers a1 and a2.
|
abstract javax.lang.model.element.AnnotationMirror |
leastUpperBound(javax.lang.model.element.AnnotationMirror a1,
javax.lang.model.element.AnnotationMirror a2)
Returns the least upper bound for the qualifiers a1 and a2.
|
java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
leastUpperBounds(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1,
java.util.Collection<javax.lang.model.element.AnnotationMirror> annos2)
Returns the type qualifiers that are the least upper bound of the qualifiers in annos1 and
annos2.
|
java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
leastUpperBounds(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1,
java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos2)
Returns the least upper bound of two types.
|
java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
leastUpperBoundsTypeVariable(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1,
java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos2)
Returns the type qualifiers that are the least upper bound of the qualifiers in annos1 and
annos2.
|
abstract javax.lang.model.element.AnnotationMirror |
leastUpperBoundTypeVariable(javax.lang.model.element.AnnotationMirror a1,
javax.lang.model.element.AnnotationMirror a2)
Returns the least upper bound for the qualifiers a1 and a2.
|
int |
numberOfIterationsBeforeWidening()
Returns the number of iterations dataflow should perform before
widenedUpperBound(AnnotationMirror, AnnotationMirror) is called or -1 if it should never be
called. |
protected java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> |
replacePolyAll(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos)
Returns a new set that is the passed set, but PolyAll has been replaced by a polymorphic
qualifiers, for hierarchies that do not have an annotation in the set.
|
<T> boolean |
updateMappingToMutableSet(java.util.Map<T,java.util.Set<javax.lang.model.element.AnnotationMirror>> map,
T key,
javax.lang.model.element.AnnotationMirror newQual)
Update a mapping from some key to a set of AnnotationMirrors.
|
javax.lang.model.element.AnnotationMirror |
widenedUpperBound(javax.lang.model.element.AnnotationMirror newQualifier,
javax.lang.model.element.AnnotationMirror previousQualifier)
If the type hierarchy has an infinite ascending chain, then the dataflow analysis might never
reach a fixed point.
|
public boolean isValid()
public int getWidth()
public abstract java.util.Set<? extends javax.lang.model.element.AnnotationMirror> getTopAnnotations()
public abstract javax.lang.model.element.AnnotationMirror getTopAnnotation(javax.lang.model.element.AnnotationMirror start)
public abstract javax.lang.model.element.AnnotationMirror getBottomAnnotation(javax.lang.model.element.AnnotationMirror start)
public abstract java.util.Set<? extends javax.lang.model.element.AnnotationMirror> getBottomAnnotations()
public abstract javax.lang.model.element.AnnotationMirror getPolymorphicAnnotation(javax.lang.model.element.AnnotationMirror start)
start
- any qualifier from the type hierarchypublic abstract java.util.Set<? extends javax.lang.model.element.AnnotationMirror> getTypeQualifiers()
public abstract boolean isSubtype(javax.lang.model.element.AnnotationMirror rhs, javax.lang.model.element.AnnotationMirror lhs)
public abstract boolean isSubtype(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> rhs, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> lhs)
public abstract javax.lang.model.element.AnnotationMirror leastUpperBound(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
Examples:
public int numberOfIterationsBeforeWidening()
widenedUpperBound(AnnotationMirror, AnnotationMirror)
is called or -1 if it should never be
called.
Subclasses overriding this method should return some positive number or -1.
widenedUpperBound(AnnotationMirror, AnnotationMirror)
is called or -1 if it should
never be called.public javax.lang.model.element.AnnotationMirror widenedUpperBound(javax.lang.model.element.AnnotationMirror newQualifier, javax.lang.model.element.AnnotationMirror previousQualifier)
numberOfIterationsBeforeWidening()
and
change its return to 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 type hierarchy has no infinite ascending chain, returns the least upper bound of the two annotations.
newQualifier
- new qualifier dataflow computed for some expressionpreviousQualifier
- the previous qualifier dataflow computed on the last iterationpublic abstract javax.lang.model.element.AnnotationMirror greatestLowerBound(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
The two qualifiers have to be from the same qualifier hierarchy. Otherwise, null will be returned.
a1
- first annotationa2
- second annotationpublic java.util.Set<? extends javax.lang.model.element.AnnotationMirror> leastUpperBounds(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos2)
Annos1 and annos2 must have the same size, and each annotation in them must be from a different type hierarchy.
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.
annos1
- first collection of qualifiersannos2
- second collection of qualifiersprotected java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> replacePolyAll(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos)
annos
- set of annotationspublic java.util.Set<? extends javax.lang.model.element.AnnotationMirror> greatestLowerBounds(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos2)
Annos1 and annos2 must have the same size, and each annotation in them must be from a different type hierarchy.
annos1
- first collection of qualifiersannos2
- second collection of qualifierspublic abstract boolean isSubtypeTypeVariable(javax.lang.model.element.AnnotationMirror subAnno, javax.lang.model.element.AnnotationMirror superAnno)
subAnno
is a sub-qualifier of superAnno
, according to the type
qualifier hierarchy. This checks only the qualifiers, not the Java type.
This method works even if the underlying Java type is a type variable. In that case, a 'null' AnnnotationMirror and the empty set represent a meaningful value (namely, no annotation).
subAnno
is a sub qualifier of superAnno
public abstract boolean isSubtypeTypeVariable(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> subAnnos, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> superAnnos)
This method works even if the underlying Java type is a type variable. In that case, a 'null' AnnnotationMirror and the empty set represent a meaningful value (namely, no annotation).
public abstract javax.lang.model.element.AnnotationMirror leastUpperBoundTypeVariable(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
Examples:
This method works even if the underlying Java type is a type variable. In that case, a 'null' AnnnotationMirror and the empty set represent a meaningful value (namely, no annotation).
public abstract javax.lang.model.element.AnnotationMirror greatestLowerBoundTypeVariable(javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
The two qualifiers have to be from the same qualifier hierarchy. Otherwise, null will be returned.
This method works even if the underlying Java type is a type variable. In that case, a 'null' AnnnotationMirror and the empty set represent a meaningful value (namely, no annotation).
a1
- first annotationa2
- second annotationpublic java.util.Set<? extends javax.lang.model.element.AnnotationMirror> leastUpperBoundsTypeVariable(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos2)
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, a 'null' AnnnotationMirror and the empty set represent a meaningful value (namely, no annotation).
public java.util.Set<? extends javax.lang.model.element.AnnotationMirror> greatestLowerBoundsTypeVariable(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos2)
The two qualifiers have to be from the same qualifier hierarchy. Otherwise, null will be returned.
This method works even if the underlying Java type is a type variable. In that case, a 'null' AnnnotationMirror and the empty set represent a meaningful value (namely, no annotation).
annos1
- first collection of qualifiersannos2
- second collection of qualifierspublic static boolean canHaveEmptyAnnotationSet(AnnotatedTypeMirror type)
public boolean isSubtype(AnnotatedTypeMirror subType, AnnotatedTypeMirror superType, javax.lang.model.element.AnnotationMirror subAnno, javax.lang.model.element.AnnotationMirror superAnno)
subAnno
is a sub-qualifier of superAnno
, 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).
subAnno
is a sub qualifier of superAnno
public boolean isSubtype(AnnotatedTypeMirror subType, AnnotatedTypeMirror superType, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> subs, java.util.Collection<javax.lang.model.element.AnnotationMirror> supers)
supers
that is a super qualifier of 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).
supers
is a super of one in subs
public javax.lang.model.element.AnnotationMirror leastUpperBound(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
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).
public javax.lang.model.element.AnnotationMirror greatestLowerBound(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, javax.lang.model.element.AnnotationMirror a1, javax.lang.model.element.AnnotationMirror a2)
The two qualifiers have to be from the same qualifier hierarchy. Otherwise, null will be returned.
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).
a1
- first annotationa2
- second annotationpublic java.util.Set<? extends javax.lang.model.element.AnnotationMirror> leastUpperBounds(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1, java.util.Collection<javax.lang.model.element.AnnotationMirror> annos2)
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).
public java.util.Set<? extends javax.lang.model.element.AnnotationMirror> greatestLowerBounds(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos1, java.util.Collection<javax.lang.model.element.AnnotationMirror> annos2)
The two qualifiers have to be from the same qualifier hierarchy. Otherwise, null will be returned.
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).
annos1
- first collection of qualifiersannos2
- second collection of qualifiers@Deprecated public javax.lang.model.element.AnnotationMirror findCorrespondingAnnotation(javax.lang.model.element.AnnotationMirror aliased, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> a)
findAnnotationInSameHierarchy(Collection, AnnotationMirror)
insteadpublic javax.lang.model.element.AnnotationMirror findAnnotationInSameHierarchy(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos, javax.lang.model.element.AnnotationMirror annotationMirror)
If the annotation in the hierarchy is PolyAll, then the polymorphic qualifier in the hierarchy is returned instead of PolyAll.
annos
- set of annotations to searchannotationMirror
- annotation that is in the same hierarchy as the returned annotation@Deprecated public javax.lang.model.element.AnnotationMirror getAnnotationInHierarchy(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos, javax.lang.model.element.AnnotationMirror annotationMirror)
findAnnotationInHierarchy(Collection, AnnotationMirror)
insteadpublic javax.lang.model.element.AnnotationMirror findAnnotationInHierarchy(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos, javax.lang.model.element.AnnotationMirror top)
If the annotation in the hierarchy is PolyAll, then the polymorphic qualifier in the hierarchy is returned instead of PolyAll.
annos
- set of annotations to searchtop
- the top annotation in the hierarchy to which the returned annotation belongspublic <T> boolean updateMappingToMutableSet(java.util.Map<T,java.util.Set<javax.lang.model.element.AnnotationMirror>> map, T key, javax.lang.model.element.AnnotationMirror newQual)
map
- the mapping to modifykey
- the key to updatenewQual
- the value to add