use of com.linkedin.pegasus.generator.spec.PrimitiveTemplateSpec in project rest.li by linkedin.
the class JavaDataTemplateGenerator method generate.
public JClass generate(ClassTemplateSpec classTemplateSpec) {
final JClass result;
if (classTemplateSpec == null) {
result = null;
} else {
if (classTemplateSpec.getSchema() == null) {
// this is for custom class, package override is not applicable.
result = getCodeModel().directClass(classTemplateSpec.getFullName());
} else if (PredefinedJavaClasses.containsKey(classTemplateSpec.getSchema())) {
final Class<?> nativeJavaClass = PredefinedJavaClasses.get(classTemplateSpec.getSchema());
result = getCodeModel().ref(nativeJavaClass);
} else if (classTemplateSpec.getSchema().isPrimitive()) {
result = generatePrimitive((PrimitiveTemplateSpec) classTemplateSpec);
} else {
try {
final JDefinedClass definedClass = defineClass(classTemplateSpec);
populateClassContent(classTemplateSpec, definedClass);
result = definedClass;
} catch (JClassAlreadyExistsException e) {
throw new IllegalArgumentException(classTemplateSpec.getFullName());
}
}
}
return result;
}
Aggregations