public class VisitHistory
extends Object
IMPORTANT: DO NOT USE VisitHistory FOR VISITORS THAT UPDATE AN ANNOTATED TYPE MIRROR'S
ANNOTATIONS OR YOU VIOLATE THE CONTRACT OF equals/Hashcode. THIS CLASS IS DESIGNED FOR
USE WITH The DefaultTypeHierarchy AND RELATED CLASSES
VisitHistory keeps track of all visits and allows clients of this class to check whether or
not they have visited a pair of AnnotatedTypeMirrors already. This is necessary in order to
halt visiting on recursive bounds. Normally, this could be done using a HashSet; this class is
necessary because of two properties of wildcards:
1) there are times when we encounter wildcards that have recursive bounds.
2) Since getEffectiveSuperBound and getEffectiveExtendsBound copy the bound before returning it,
two calls that should return the same bound will NOT return objects that are .equals to each other.
E.g.
AnnotatedWildcardType wc = ...
wc.getEffectiveSuperBound().equals(wc.getEffectiveSuperBound())
// the above line will return false if the super bound is a wildcard
// because two wildcards are .equals only if they are also referentially (==) equal
// and each call to getEffectiveSuperBound returns a copy of the original bound
When we encounter types with property 1, property 2 ensures we cannot stop recursively comparing
the bounds because the equals method will not return true when we encounter a copy of a bound we have
already explored. This class defines a "Visit" inner class which consists of a pair of AnnotatedTypeMirrors.
Its equalityCompare method compares AnnotatedTypeMirrors in a way that identifies wildcards that
have already been compared.