code: private static <T> void mapTypeVariablesToArguments(final Class<T> cls,
              final ParameterizedType parameterizedType, final Map<TypeVariable<?>, Type> typeVarAssigns) {
          // capture the type variables from the owner type that have assignments
          final Type ownerType = parameterizedType.getOwnerType();
  
          if (ownerType instanceof ParameterizedType) {
              // recursion to make sure the owner's owner type gets processed
              mapTypeVariablesToArguments(cls, (ParameterizedType) ownerType, typeVarAssigns);
          }
  
          // parameterizedType is a generic interface/class (or it's in the owner
          // hierarchy of said interface/class) implemented/extended by the class
          // cls. Find out which type variables of cls are type arguments of
          // parameterizedType:
          final Type[] typeArgs = parameterizedType.getActualTypeArguments();
  
          // of the cls's type variables that are arguments of parameterizedType,
          // find out which ones can be determined from the super type's arguments
          final TypeVariable<?>[] typeVars = getRawType(parameterizedType).getTypeParameters();
  
          // use List view of type parameters of cls so the contains() method can be used:
          final List<TypeVariable<Class<T>>> typeVarList = Arrays.asList(cls
                  .getTypeParameters());
  
          for (int i = 0; i < typeArgs.length; i++) {
              final TypeVariable<?> typeVar = typeVars[i];
              final Type typeArg = typeArgs[i];
  
              // argument of parameterizedType is a type variable of cls
              if (typeVarList.contains(typeArg)
              // type variable of parameterizedType has an assignment in
                      // the super type.
                      && typeVarAssigns.containsKey(typeVar)) {
                  // map the assignment to the cls's type variable
                  typeVarAssigns.put((TypeVariable<?>) typeArg, typeVarAssigns.get(typeVar));
              }
          }
      }
docs: <p>Performs a mapping of type variables.</p>
  
  @param <T> the generic type of the class in question
  @param cls the class in question
  @param parameterizedType the parameterized type
  @param typeVarAssigns the map to be filled