code: public static Type resolveTypeVariable(Class<?> root, TypeVariable<?> typeVariable) {
          if (typeVariable.getGenericDeclaration() instanceof Class<?>) {
              Class<?> classDeclaringTypeVariable = (Class<?>) typeVariable.getGenericDeclaration();
              Type[] types = findParameterizedTypes(root, classDeclaringTypeVariable);
              if (types == null)
                  return null;
              for (int i = 0; i < types.length; i++) {
                  TypeVariable<?> tv = classDeclaringTypeVariable.getTypeParameters()[i];
                  if (tv.equals(typeVariable)) {
                      return types[i];
                  }
              }
          }
          return null;
      }
docs: Finds an actual value of a type variable. The method looks in a class
  hierarchy for a class defining the variable and returns the value if
  present.
  
  @param root
  @param typeVariable
  @return actual type of the type variable