in dataenum-processor/src/main/java/com/spotify/dataenum/processor/generator/value/ValueTypeFactory.java [351:370]
private static MethodSpec createAsSpecMethod(OutputValue value, OutputSpec spec) {
List<TypeVariableName> missingTypeVariables = extractMissingTypeVariablesForValue(value, spec);
Builder builder =
MethodSpec.methodBuilder("as" + spec.outputClass().simpleName())
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.returns(spec.parameterizedOutputClass())
.addTypeVariables(missingTypeVariables)
.addStatement("return ($T) this", spec.parameterizedOutputClass());
// if there are type variables that this sub-type doesn't use, they will lead to 'unchecked
// cast'
// warnings when compiling the generated code. These warnings are safe to suppress, since this
// sub type will never use those type variables.
if (!missingTypeVariables.isEmpty()) {
builder.addAnnotation(SUPPRESS_UNCHECKED_WARNINGS);
}
return builder.build();
}