private static @Nullable Class<?> doSubstituteGenericType(@NotNull Type genericType, @NotNull Type classType) {
    if (genericType instanceof TypeVariable) {
      final Class<?> aClass = ClassUtil.getRawType(classType);
      final Type type = ClassUtil.resolveVariable((TypeVariable<?>)genericType, aClass, true);
      if (type instanceof Class) {
        return (Class<?>)type;
      }
      if (type instanceof ParameterizedType) {
        return (Class<?>)((ParameterizedType)type).getRawType();
      }
      if (type instanceof TypeVariable && classType instanceof ParameterizedType) {
        final int index = ArrayUtilRt.find(aClass.getTypeParameters(), type);
        if (index >= 0) {
          return ClassUtil.getRawType(((ParameterizedType)classType).getActualTypeArguments()[index]);
        }
      }
    }
    else {
      return ClassUtil.getRawType(genericType);
    }
    return null;
  }
private static @Nullable Class<?> doSubstituteGenericType(@NotNull Type genericType, @NotNull Type classType)