public class SubtypeVisitHistory extends Object
VisitHistory tracks triples of (type1, type2, top), where type1 is a subtype of type2. It does not track when type1 is not a subtype of type2; such entries are missing from the history. Clients of this class can check whether or not they have visited an equivalent pair of AnnotatedTypeMirrors already. This is necessary in order to halt visiting on recursive bounds.
This class is primarily used to implement isSubtype(ATM, ATM). The pair of types corresponds
to the subtype and the supertype being checked. A single subtype may be visited more than once,
but with a different supertype. For example, if the two types are @A T extends @B
Serializable<T>
and @C Serializable<?>
, then isSubtype is first called one those types
and then on @B Serializable<T>
and @C Serializable<?>
.
Constructor and Description |
---|
SubtypeVisitHistory() |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
AnnotationMirror currentTop)
Returns true if type1 and type2 (or an equivalent pair) have been passed to the put method
previously.
|
void |
put(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
AnnotationMirror currentTop,
boolean isSubtype)
Put a visit for
type1 , type2 , and top in the history. |
void |
remove(AnnotatedTypeMirror type1,
AnnotatedTypeMirror type2,
AnnotationMirror currentTop)
Remove
type1 and type2 . |
String |
toString() |
public void put(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, AnnotationMirror currentTop, boolean isSubtype)
type1
, type2
, and top
in the history. Has no effect if
isSubtype is false.type1
- the first typetype2
- the second typecurrentTop
- the top of the relevant type hierarchy; only annotations from that hierarchy
are consideredisSubtype
- whether type1
is a subtype of type2
; if false, this method
does nothingpublic void remove(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, AnnotationMirror currentTop)
type1
and type2
.public boolean contains(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2, AnnotationMirror currentTop)