private static TypeName getSuperclassForValue()

in dataenum-processor/src/main/java/com/spotify/dataenum/processor/generator/value/ValueTypeFactory.java [89:112]


  private static TypeName getSuperclassForValue(OutputValue value, OutputSpec spec)
      throws ParserException {
    if (!spec.hasTypeVariables()) {
      return spec.outputClass();
    }

    List<TypeName> superParameters = new ArrayList<>();
    for (TypeVariableName typeVariable : spec.typeVariables()) {
      if (Iterables.contains(value.typeVariables(), typeVariable)) {
        superParameters.add(typeVariable);
      } else {
        if (typeVariable.bounds.size() == 0) {
          superParameters.add(TypeName.OBJECT);
        } else if (typeVariable.bounds.size() == 1) {
          superParameters.add(typeVariable.bounds.get(0));
        } else {
          throw new ParserException("More than one generic type bound is not supported ");
        }
      }
    }

    return ParameterizedTypeName.get(
        spec.outputClass(), superParameters.toArray(new TypeName[] {}));
  }