use of com.linkedin.pegasus.generator.spec.EnumTemplateSpec in project rest.li by linkedin.
the class TemplateSpecGenerator method generateEnum.
private ClassTemplateSpec generateEnum(EnumDataSchema schema) {
final EnumTemplateSpec enumClass = new EnumTemplateSpec(schema);
enumClass.setNamespace(schema.getNamespace());
enumClass.setPackage(schema.getPackage());
enumClass.setClassName(schema.getName());
enumClass.setModifiers(ModifierSpec.PUBLIC);
registerClassTemplateSpec(schema, enumClass);
return enumClass;
}
use of com.linkedin.pegasus.generator.spec.EnumTemplateSpec in project rest.li by linkedin.
the class JavaDataTemplateGenerator method defineClass.
private JDefinedClass defineClass(ClassTemplateSpec classTemplateSpec) throws JClassAlreadyExistsException {
JDefinedClass result = _definedClasses.get(classTemplateSpec);
if (result == null) {
final int jmodValue = getJModValue(classTemplateSpec.getModifiers());
final JClassContainer container;
if (classTemplateSpec.getEnclosingClass() == null) {
container = getPackage(classTemplateSpec.getPackage());
} else {
container = defineClass(classTemplateSpec.getEnclosingClass());
}
if (classTemplateSpec instanceof ArrayTemplateSpec || classTemplateSpec instanceof FixedTemplateSpec || classTemplateSpec instanceof MapTemplateSpec || classTemplateSpec instanceof RecordTemplateSpec || classTemplateSpec instanceof TyperefTemplateSpec || classTemplateSpec instanceof UnionTemplateSpec) {
result = container._class(jmodValue, escapeReserved(classTemplateSpec.getClassName()));
} else if (classTemplateSpec instanceof EnumTemplateSpec) {
result = container._class(jmodValue, escapeReserved(classTemplateSpec.getClassName()), ClassType.ENUM);
} else {
throw new RuntimeException();
}
_definedClasses.put(classTemplateSpec, result);
}
return result;
}
Aggregations