use of com.linkedin.pegasus.generator.spec.FixedTemplateSpec in project rest.li by linkedin.
the class TemplateSpecGenerator method generateFixed.
private ClassTemplateSpec generateFixed(FixedDataSchema schema) {
final FixedTemplateSpec fixedClass = new FixedTemplateSpec(schema);
fixedClass.setNamespace(schema.getNamespace());
fixedClass.setPackage(schema.getPackage());
fixedClass.setClassName(schema.getName());
fixedClass.setModifiers(ModifierSpec.PUBLIC);
registerClassTemplateSpec(schema, fixedClass);
return fixedClass;
}
use of com.linkedin.pegasus.generator.spec.FixedTemplateSpec 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