code: public static Type resolveTypeVariable(List<Type> context, TypeVariable<?> typeVariable) {
      // determine where the type variable was declared
      GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
      if (genericDeclaration instanceof Class<?>) {
        Class<?> rawGenericDeclaration = (Class<?>) genericDeclaration;
        // check if the context extends that declaration
        int contextIndex = context.size();
        ParameterizedType parameterizedType = null;
        while (parameterizedType == null && --contextIndex >= 0) {
          parameterizedType =
              getSuperParameterizedType(context.get(contextIndex), rawGenericDeclaration);
        }
        if (parameterizedType != null) {
          // find the type variable's index in the declaration's type parameters
          TypeVariable<?>[] typeParameters = genericDeclaration.getTypeParameters();
          int index = 0;
          for (; index < typeParameters.length; index++) {
            TypeVariable<?> typeParameter = typeParameters[index];
            if (typeParameter.equals(typeVariable)) {
              break;
            }
          }
          // use that index to get the actual type argument
          Type result = parameterizedType.getActualTypeArguments()[index];
          if (result instanceof TypeVariable<?>) {
            // attempt to resolve type variable
            Type resolve = resolveTypeVariable(context, (TypeVariable<?>) result);
            if (resolve != null) {
              return resolve;
            }
            // partially resolved type variable is okay
          }
          return result;
        }
      }
      return null;
    }
docs: Resolves the actual type of the given type variable that comes from a field type based on the
  given context list.
  
  <p>In case the type variable can be resolved partially, it will return the partially resolved
  type variable.
  
  @param context context list, ordering from least specific to most specific type context, for
  example container class and then its field
  @param typeVariable type variable
  @return resolved or partially resolved actual type (type variable, class, parameterized type,
  or generic array type, but not wildcard type) or {@code null} if unable to resolve at all