public interface TypesVisitor
TypesWalker. Used to walk on two types synchronously.
Types hierarchy is assumed to be compatible. Use cases: types compatibility or deep comparision.
Primitive types will never appear in visitor: wrapper types are used instead for simplicity (e.g. Integer for int).
CompatibilityTypesVisitor| Modifier and Type | Method and Description |
|---|---|
void |
incompatibleHierarchy(java.lang.reflect.Type one,
java.lang.reflect.Type two)
Called when synchronous walk is impossible.
|
boolean |
next(java.lang.reflect.Type one,
java.lang.reflect.Type two)
Method is called for each matching types pair in types hierarchy.
|
boolean next(java.lang.reflect.Type one,
java.lang.reflect.Type two)
List<String> and ArrayList<String> will lead to two calls with
List<String>, ArrayList<String> and then String, String. Method may return false
to stop types traversing.
When types are not compatible then incompatibleHierarchy(Type, Type) is called instead.
Passed types are always compatible on current level. For example List<String> and List<Integer>
are compatible on class level (assumed as List and List, but on the next level incompatible
type will be notified. Overall two visitor calls will be done: next(Type, Type) for lists and
incompatibleHierarchy(Type, Type) for list generics.
If one of the types is Object then it will be the last step (no hierarchy incompatibility will be
called as object is compatible with everything - we just can't go further because of not enough information).
one - current class in first hierarchytwo - class from second hierarchy, but from the same place (in type tree)void incompatibleHierarchy(java.lang.reflect.Type one,
java.lang.reflect.Type two)
one - current type from hierarchy one (not root type)two - current type from hierarchy two