Class VariableTypeInheritanceSearch


  • public class VariableTypeInheritanceSearch
    extends java.lang.Object
    Search for type variable in inheritance hierarchy and resolve if possible.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.reflect.Type searchParametrizedType​(java.lang.reflect.Type typeToSearch, java.lang.reflect.TypeVariable<?> typeVar)
      Searches the hierarchy of classes to resolve a type variable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • VariableTypeInheritanceSearch

        public VariableTypeInheritanceSearch()
    • Method Detail

      • searchParametrizedType

        public java.lang.reflect.Type searchParametrizedType​(java.lang.reflect.Type typeToSearch,
                                                             java.lang.reflect.TypeVariable<?> typeVar)
        Searches the hierarchy of classes to resolve a type variable. If typevar resolved value is another typevar redirection (propagated from wrapping class), this typevar is returned.
        
         Example 1: typevar is resolved
        
        
         class GenericClass <T> {
             private T genericField;
         }
         class ConcreteClass extends GenericClass<MyPojo> {
             //...
         }
        
         In above case when ConcreteClass type is passed as runtime type and <T> as type variable, T is resolved to MyPojo.
         
         Example 2: typevar is resolved to another propagated typevar
        
        
         class WrapperGenericClass<X> {
             private GenericClass<X> propagatedGenericField
         }
        
         class AnotherClass extends WrapperGenericClass<MyPojo> {
         }
        
        
         In second case when GenericClass ParameterizedType is passed as runtime type and <T> as type variable,
         T is resolved to propagated <X> by WrapperGenericClass.
        
         Resolution on <X> must be performed thereafter with AnotherClass runtime type.
         
        Parameters:
        typeToSearch - runtime type to search for typevar in, not null
        typeVar - type variable to resolve, not null
        Returns:
        resolved runtime type, or type variable