code: private static void buildTypeVariableMap(ParameterizedType type,
                                               Map<TypeVariable<?>, Type> typeVariableMap) {
          if (type.getRawType() instanceof Class) {
              TypeVariable<?>[] typeVariables = ((Class<?>) type.getRawType()).getTypeParameters();
              Type[] typeArguments = type.getActualTypeArguments();
  
              for (int i = 0; i < typeArguments.length; i++) {
                  TypeVariable<?> variable = typeVariables[i];
                  Type typeArgument = typeArguments[i];
  
                  if (typeArgument instanceof Class) {
                      typeVariableMap.put(variable, typeArgument);
                  } else if (typeArgument instanceof GenericArrayType) {
                      typeVariableMap.put(variable, typeArgument);
                  } else if (typeArgument instanceof ParameterizedType) {
                      typeVariableMap.put(variable, typeArgument);
                  } else if (typeArgument instanceof TypeVariable) {
                      TypeVariable<?> typeVariableArgument = (TypeVariable<?>) typeArgument;
                      Type resolvedType = typeVariableMap.get(typeVariableArgument);
                      if (resolvedType == null)
                          resolvedType = resolveBound(typeVariableArgument);
                      typeVariableMap.put(variable, resolvedType);
                  }
              }
          }
      }
docs: Populates the {@code typeVariableMap} with type arguments and parameters for the given
  {@code type}.