public class MultiGraphQualifierHierarchy extends QualifierHierarchy
This class is immutable and can be only created through MultiGraphQualifierHierarchy.MultiGraphFactory
.
Modifier and Type | Class and Description |
---|---|
static class |
MultiGraphQualifierHierarchy.MultiGraphFactory
Factory used to create an instance of
GraphQualifierHierarchy . |
Modifier and Type | Field and Description |
---|---|
protected Set<AnnotationMirror> |
bottoms
The bottom qualifiers of the type hierarchies.
|
protected AnnotationMirror |
polymorphicQualifier
Reference to the special qualifier org.checkerframework.framework.qual.PolymorphicQualifier.
|
protected Map<AnnotationMirror,AnnotationMirror> |
polyQualifiers |
protected Map<AnnotationMirror,Set<AnnotationMirror>> |
supertypesDirect
The declared, direct supertypes for each qualifier, without added transitive relations.
|
protected Map<AnnotationMirror,Set<AnnotationMirror>> |
supertypesTransitive
The transitive closure of the supertypesDirect.
|
protected Set<AnnotationMirror> |
tops
The top qualifiers of the individual type hierarchies.
|
Constructor and Description |
---|
MultiGraphQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory f) |
MultiGraphQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory f,
Object... args) |
Modifier and Type | Method and Description |
---|---|
protected void |
addPolyRelations(QualifierHierarchy qualHierarchy,
Map<AnnotationMirror,Set<AnnotationMirror>> fullMap,
Map<AnnotationMirror,AnnotationMirror> polyQualifiers,
Set<AnnotationMirror> tops,
Set<AnnotationMirror> bottoms)
Add the relationships for polymorphic qualifiers.
|
protected Set<AnnotationMirror> |
findBottoms(Map<AnnotationMirror,Set<AnnotationMirror>> supertypes)
Infer the bottoms of the subtype hierarchy.
|
protected AnnotationMirror |
findLub(AnnotationMirror a1,
AnnotationMirror a2)
Finds and returns the Least Upper Bound (LUB) of two annotation mirrors a1 and a2 by
recursively climbing the qualifier hierarchy of a1 until one of them is a subtype of the
other, or returns null if no subtype relationships can be found.
|
protected Set<AnnotationMirror> |
findTops(Map<AnnotationMirror,Set<AnnotationMirror>> supertypes)
Infer the tops of the subtype hierarchy.
|
protected void |
finish(QualifierHierarchy qualHierarchy,
Map<AnnotationMirror,Set<AnnotationMirror>> supertypesTransitive,
Map<AnnotationMirror,AnnotationMirror> polyQualifiers,
Set<AnnotationMirror> tops,
Set<AnnotationMirror> bottoms,
Object... args)
Method to finalize the qualifier hierarchy before it becomes unmodifiable.
|
AnnotationMirror |
getBottomAnnotation(AnnotationMirror start)
Return the bottom for the given qualifier, that is, the qualifier that is a subtype of start
but no further subtypes exist.
|
Set<? extends AnnotationMirror> |
getBottomAnnotations() |
AnnotationMirror |
getPolymorphicAnnotation(AnnotationMirror start) |
AnnotationMirror |
getTopAnnotation(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.
|
Set<? extends AnnotationMirror> |
getTopAnnotations() |
Set<? extends AnnotationMirror> |
getTypeQualifiers()
Deprecated.
|
AnnotationMirror |
greatestLowerBound(AnnotationMirror a1,
AnnotationMirror a2)
Returns the greatest lower bound for the qualifiers a1 and a2.
|
AnnotationMirror |
greatestLowerBoundTypeVariable(AnnotationMirror a1,
AnnotationMirror a2)
Returns the greatest lower bound for the qualifiers a1 and a2.
|
boolean |
isSubtype(AnnotationMirror subAnno,
AnnotationMirror superAnno)
Tests whether rhs is equal to or a sub-qualifier of lhs, according to the type qualifier
hierarchy.
|
boolean |
isSubtype(Collection<? extends AnnotationMirror> rhs,
Collection<? extends AnnotationMirror> lhs)
Tests whether there is any annotation in lhs that is a super qualifier of some annotation in
rhs.
|
boolean |
isSubtypeTypeVariable(AnnotationMirror subAnno,
AnnotationMirror superAnno)
Tests whether
subAnno is a sub-qualifier of superAnno , according to the type
qualifier hierarchy. |
boolean |
isSubtypeTypeVariable(Collection<? extends AnnotationMirror> subAnnos,
Collection<? extends AnnotationMirror> superAnnos)
Tests whether there is any annotation in superAnnos that is a super qualifier of some
annotation in subAnnos.
|
AnnotationMirror |
leastUpperBound(AnnotationMirror a1,
AnnotationMirror a2)
Returns the least upper bound for the qualifiers a1 and a2.
|
AnnotationMirror |
leastUpperBoundTypeVariable(AnnotationMirror a1,
AnnotationMirror a2)
Returns the least upper bound for the qualifiers a1 and a2.
|
String |
toString() |
protected Map<AnnotationMirror,Set<AnnotationMirror>> |
transitiveClosure(Map<AnnotationMirror,Set<AnnotationMirror>> supertypes)
Computes the transitive closure of the given map and returns it.
|
canHaveEmptyAnnotationSet, findAnnotationInHierarchy, findAnnotationInSameHierarchy, getWidth, greatestLowerBound, greatestLowerBounds, greatestLowerBounds, greatestLowerBoundsTypeVariable, isSubtype, isSubtype, isValid, leastUpperBound, leastUpperBounds, leastUpperBounds, leastUpperBoundsTypeVariable, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBound
protected final Map<AnnotationMirror,Set<AnnotationMirror>> supertypesDirect
protected final Map<AnnotationMirror,Set<AnnotationMirror>> supertypesTransitive
protected final Set<AnnotationMirror> tops
protected final Set<AnnotationMirror> bottoms
protected final AnnotationMirror polymorphicQualifier
protected final Map<AnnotationMirror,AnnotationMirror> polyQualifiers
public MultiGraphQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory f)
public MultiGraphQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory f, Object... args)
protected void finish(QualifierHierarchy qualHierarchy, Map<AnnotationMirror,Set<AnnotationMirror>> supertypesTransitive, Map<AnnotationMirror,AnnotationMirror> polyQualifiers, Set<AnnotationMirror> tops, Set<AnnotationMirror> bottoms, Object... args)
@SideEffectFree public String toString()
public Set<? extends AnnotationMirror> getTopAnnotations()
getTopAnnotations
in class QualifierHierarchy
public AnnotationMirror getTopAnnotation(AnnotationMirror start)
QualifierHierarchy
getTopAnnotation
in class QualifierHierarchy
public Set<? extends AnnotationMirror> getBottomAnnotations()
getBottomAnnotations
in class QualifierHierarchy
public AnnotationMirror getBottomAnnotation(AnnotationMirror start)
QualifierHierarchy
getBottomAnnotation
in class QualifierHierarchy
public AnnotationMirror getPolymorphicAnnotation(AnnotationMirror start)
getPolymorphicAnnotation
in class QualifierHierarchy
start
- any qualifier from the type hierarchynull
if there is no
polymorphic qualifier in that hierarchypublic boolean isSubtype(Collection<? extends AnnotationMirror> rhs, Collection<? extends AnnotationMirror> lhs)
QualifierHierarchy
isSubtype
in class QualifierHierarchy
public boolean isSubtypeTypeVariable(Collection<? extends AnnotationMirror> subAnnos, Collection<? extends AnnotationMirror> superAnnos)
QualifierHierarchy
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).
isSubtypeTypeVariable
in class QualifierHierarchy
@Deprecated public Set<? extends AnnotationMirror> getTypeQualifiers()
QualifierHierarchy
getTypeQualifiers
in class QualifierHierarchy
public AnnotationMirror leastUpperBound(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchy
Examples:
leastUpperBound
in class QualifierHierarchy
public AnnotationMirror leastUpperBoundTypeVariable(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchy
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).
leastUpperBoundTypeVariable
in class QualifierHierarchy
public AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchy
The two qualifiers have to be from the same qualifier hierarchy. Otherwise, null will be returned.
greatestLowerBound
in class QualifierHierarchy
a1
- first annotationa2
- second annotationpublic AnnotationMirror greatestLowerBoundTypeVariable(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchy
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).
greatestLowerBoundTypeVariable
in class QualifierHierarchy
a1
- first annotationa2
- second annotationpublic boolean isSubtype(AnnotationMirror subAnno, AnnotationMirror superAnno)
Most qualifiers have no value fields. However, two annotations with values are subtype of each other only if they have the same values. i.e. I(m) is a subtype of I(n) iff m = n.
When client specifies an annotation, a1, to be a subtype of annotation with values, a2, then a1 is a subtype of all instances of a2 regardless of a2 values.
isSubtype
in class QualifierHierarchy
subAnno
- the sub qualifiersuperAnno
- the super qualifierpublic boolean isSubtypeTypeVariable(AnnotationMirror subAnno, AnnotationMirror superAnno)
QualifierHierarchy
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).
isSubtypeTypeVariable
in class QualifierHierarchy
subAnno
is a sub qualifier of superAnno
protected Set<AnnotationMirror> findTops(Map<AnnotationMirror,Set<AnnotationMirror>> supertypes)
protected Set<AnnotationMirror> findBottoms(Map<AnnotationMirror,Set<AnnotationMirror>> supertypes)
protected Map<AnnotationMirror,Set<AnnotationMirror>> transitiveClosure(Map<AnnotationMirror,Set<AnnotationMirror>> supertypes)
protected void addPolyRelations(QualifierHierarchy qualHierarchy, Map<AnnotationMirror,Set<AnnotationMirror>> fullMap, Map<AnnotationMirror,AnnotationMirror> polyQualifiers, Set<AnnotationMirror> tops, Set<AnnotationMirror> bottoms)
A polymorphic qualifier, such as PolyNull
, needs to be:
Nullable
)
NonNull
)
protected AnnotationMirror findLub(AnnotationMirror a1, AnnotationMirror a2)
a1
- first annotation mirrora2
- second annotation mirror