Search in sources :

Example 1 with FixedTemplateSpec

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;
}
Also used : FixedTemplateSpec(com.linkedin.pegasus.generator.spec.FixedTemplateSpec)

Example 2 with FixedTemplateSpec

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;
}
Also used : JDefinedClass(com.sun.codemodel.JDefinedClass) FixedTemplateSpec(com.linkedin.pegasus.generator.spec.FixedTemplateSpec) MapTemplateSpec(com.linkedin.pegasus.generator.spec.MapTemplateSpec) EnumTemplateSpec(com.linkedin.pegasus.generator.spec.EnumTemplateSpec) TyperefTemplateSpec(com.linkedin.pegasus.generator.spec.TyperefTemplateSpec) UnionTemplateSpec(com.linkedin.pegasus.generator.spec.UnionTemplateSpec) RecordTemplateSpec(com.linkedin.pegasus.generator.spec.RecordTemplateSpec) JClassContainer(com.sun.codemodel.JClassContainer) ArrayTemplateSpec(com.linkedin.pegasus.generator.spec.ArrayTemplateSpec)

Aggregations

FixedTemplateSpec (com.linkedin.pegasus.generator.spec.FixedTemplateSpec)2 ArrayTemplateSpec (com.linkedin.pegasus.generator.spec.ArrayTemplateSpec)1 EnumTemplateSpec (com.linkedin.pegasus.generator.spec.EnumTemplateSpec)1 MapTemplateSpec (com.linkedin.pegasus.generator.spec.MapTemplateSpec)1 RecordTemplateSpec (com.linkedin.pegasus.generator.spec.RecordTemplateSpec)1 TyperefTemplateSpec (com.linkedin.pegasus.generator.spec.TyperefTemplateSpec)1 UnionTemplateSpec (com.linkedin.pegasus.generator.spec.UnionTemplateSpec)1 JClassContainer (com.sun.codemodel.JClassContainer)1 JDefinedClass (com.sun.codemodel.JDefinedClass)1