public class MultiGraphQualifierHierarchy extends Object implements 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 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
qualifier but no further subtypes exist. |
Set<? extends AnnotationMirror> |
getBottomAnnotations()
Returns the bottom type qualifiers in the hierarchy.
|
AnnotationMirror |
getPolymorphicAnnotation(AnnotationMirror start)
Returns the polymorphic qualifier for the hierarchy containing
qualifier , or null if there is no polymorphic qualifier in that hierarchy. |
AnnotationMirror |
getTopAnnotation(AnnotationMirror start)
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.
|
AnnotationMirror |
greatestLowerBound(AnnotationMirror a1,
AnnotationMirror a2)
Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.
|
boolean |
isPolymorphicQualifier(AnnotationMirror qual)
Returns
true if the qualifier is a polymorphic qualifier; otherwise, returns false . |
boolean |
isSubtype(AnnotationMirror subAnno,
AnnotationMirror superAnno)
Tests whether
subQualifier is equal to or a sub-qualifier of superQualifier ,
according to the type qualifier hierarchy. |
boolean |
isSubtype(Collection<? extends AnnotationMirror> rhs,
Collection<? extends AnnotationMirror> lhs)
Tests whether all qualifiers in
subQualifiers are a subqualifier or equal to the
qualifier in the same hierarchy in superQualifiers . |
boolean |
isValid()
Determine whether this is valid.
|
AnnotationMirror |
leastUpperBound(AnnotationMirror a1,
AnnotationMirror a2)
Returns the least upper bound (LUB) of the qualifiers
qualifier1 and qualifier2 . |
String |
toString() |
protected Map<AnnotationMirror,Set<AnnotationMirror>> |
transitiveClosure(Map<AnnotationMirror,Set<AnnotationMirror>> supertypes)
Computes the transitive closure of the given map and returns it.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
assertSameSize, assertSameSize, canHaveEmptyAnnotationSet, findAnnotationInHierarchy, findAnnotationInSameHierarchy, getWidth, greatestLowerBound, greatestLowerBounds, greatestLowerBounds, greatestLowerBoundsTypeVariable, greatestLowerBoundTypeVariable, isSubtype, isSubtype, isSubtypeTypeVariable, isSubtypeTypeVariable, leastUpperBound, leastUpperBounds, leastUpperBounds, leastUpperBoundsTypeVariable, leastUpperBoundTypeVariable, 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 Map<AnnotationMirror,AnnotationMirror> polyQualifiers
public MultiGraphQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory f)
public MultiGraphQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory f, Object... args)
public boolean isValid()
QualifierHierarchy
isValid
in interface QualifierHierarchy
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()
QualifierHierarchy
QualifierHierarchy.getWidth()
.getTopAnnotations
in interface QualifierHierarchy
public AnnotationMirror getTopAnnotation(AnnotationMirror start)
QualifierHierarchy
qualifier
but no further supertypes exist.getTopAnnotation
in interface QualifierHierarchy
start
- any qualifier from one of the qualifier hierarchies represented by thisqualifier
's hierarchypublic Set<? extends AnnotationMirror> getBottomAnnotations()
QualifierHierarchy
QualifierHierarchy.getWidth()
.getBottomAnnotations
in interface QualifierHierarchy
public AnnotationMirror getBottomAnnotation(AnnotationMirror start)
QualifierHierarchy
qualifier
but no further subtypes exist.getBottomAnnotation
in interface QualifierHierarchy
start
- any qualifier from one of the qualifier hierarchies represented by thisqualifier
's hierarchypublic AnnotationMirror getPolymorphicAnnotation(AnnotationMirror start)
QualifierHierarchy
qualifier
, or null
if there is no polymorphic qualifier in that hierarchy.getPolymorphicAnnotation
in interface QualifierHierarchy
start
- any qualifier from one of the qualifier hierarchies represented by thisqualifier
, or null
if there is no polymorphic qualifier in that hierarchypublic boolean isSubtype(Collection<? extends AnnotationMirror> rhs, Collection<? extends AnnotationMirror> lhs)
QualifierHierarchy
subQualifiers
are a subqualifier or equal to the
qualifier in the same hierarchy in superQualifiers
.isSubtype
in interface QualifierHierarchy
rhs
- set of qualifiers; exactly one per hierarchylhs
- set of qualifiers; exactly one per hierarchysubQualifiers
are a subqualifier or equal to the
qualifier in the same hierarchy in superQualifiers
public AnnotationMirror leastUpperBound(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchy
qualifier1
and qualifier2
. Returns null
if the qualifiers are not from the same qualifier
hierarchy.
Examples:
leastUpperBound
in interface QualifierHierarchy
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 hierarchiespublic AnnotationMirror greatestLowerBound(AnnotationMirror a1, AnnotationMirror a2)
QualifierHierarchy
greatestLowerBound
in interface QualifierHierarchy
a1
- first qualifiera2
- second qualifierpublic boolean isSubtype(AnnotationMirror subAnno, AnnotationMirror superAnno)
subQualifier
is equal to or a sub-qualifier of superQualifier
,
according to the type qualifier hierarchy.
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 interface QualifierHierarchy
subAnno
- the sub qualifiersuperAnno
- the super qualifiersubQualifier
is a subqualifier of, or equal to, superQualifier
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 mirrorpublic boolean isPolymorphicQualifier(AnnotationMirror qual)
QualifierHierarchy
true
if the qualifier is a polymorphic qualifier; otherwise, returns false
.isPolymorphicQualifier
in interface QualifierHierarchy
qual
- qualifiertrue
if the qualifier is a polymorphic qualifier; otherwise, returns false
.