@NotNull
  @Override
  public PsiClassType createType(@NotNull final PsiClass aClass, final PsiType parameter) {
    final PsiTypeParameter[] typeParameters = aClass.getTypeParameters();
    assert typeParameters.length == 1 : aClass;

    return createType(aClass, PsiSubstitutor.EMPTY.put(typeParameters[0], parameter));
  }
  public static PsiSubstitutor substituteByParameterName(
      final PsiClass psiClass, final PsiSubstitutor parentSubstitutor) {

    final Map<PsiTypeParameter, PsiType> substitutionMap = parentSubstitutor.getSubstitutionMap();
    final List<PsiType> result = new ArrayList<PsiType>(substitutionMap.size());
    for (PsiTypeParameter typeParameter : psiClass.getTypeParameters()) {
      final String name = typeParameter.getName();
      final PsiTypeParameter key =
          ContainerUtil.find(
              substitutionMap.keySet(),
              new Condition<PsiTypeParameter>() {
                @Override
                public boolean value(final PsiTypeParameter psiTypeParameter) {
                  return name.equals(psiTypeParameter.getName());
                }
              });
      if (key != null) {
        result.add(substitutionMap.get(key));
      }
    }
    return PsiSubstitutor.EMPTY.putAll(
        psiClass, result.toArray(PsiType.createArray(result.size())));
  }
 @NotNull
 @Override
 public PsiClassType createType(@NotNull final PsiClass aClass, final PsiType... parameters) {
   return createType(aClass, PsiSubstitutor.EMPTY.putAll(aClass, parameters));
 }