Search in sources :

Example 26 with JMethod

use of com.sun.codemodel.JMethod in project rest.li by linkedin.

the class JavaDataTemplateGenerator method generateConstructorWithNoArg.

private static void generateConstructorWithNoArg(JDefinedClass cls, JVar schemaField, JClass newClass) {
    final JMethod noArgConstructor = cls.constructor(JMod.PUBLIC);
    noArgConstructor.body().invoke(SUPER).arg(JExpr._new(newClass)).arg(schemaField);
}
Also used : JMethod(com.sun.codemodel.JMethod)

Example 27 with JMethod

use of com.sun.codemodel.JMethod in project rest.li by linkedin.

the class JavaDataTemplateGenerator method generateConstructorWithInitialCapacityAndLoadFactor.

private void generateConstructorWithInitialCapacityAndLoadFactor(JDefinedClass cls) {
    final JMethod argConstructor = cls.constructor(JMod.PUBLIC);
    final JVar initialCapacity = argConstructor.param(getCodeModel().INT, "initialCapacity");
    final JVar loadFactor = argConstructor.param(getCodeModel().FLOAT, "loadFactor");
    argConstructor.body().invoke(THIS).arg(JExpr._new(_dataMapClass).arg(initialCapacity).arg(loadFactor));
}
Also used : JMethod(com.sun.codemodel.JMethod) JVar(com.sun.codemodel.JVar)

Example 28 with JMethod

use of com.sun.codemodel.JMethod in project rest.li by linkedin.

the class JavaDataTemplateGenerator method generateFixed.

protected void generateFixed(JDefinedClass fixedClass, FixedTemplateSpec fixedSpec) {
    fixedClass.javadoc().append(fixedSpec.getSchema().getDoc());
    setDeprecatedAnnotationAndJavadoc(fixedSpec.getSchema(), fixedClass);
    fixedClass._extends(FixedTemplate.class);
    final JVar schemaField = generateSchemaField(fixedClass, fixedSpec.getSchema());
    final JMethod bytesConstructor = fixedClass.constructor(JMod.PUBLIC);
    final JVar param = bytesConstructor.param(ByteString.class, "value");
    bytesConstructor.body().invoke(SUPER).arg(param).arg(schemaField);
    generateConstructorWithObjectArg(fixedClass, schemaField);
    if (_copierMethods) {
        generateCopierMethods(fixedClass);
    }
}
Also used : JMethod(com.sun.codemodel.JMethod) JVar(com.sun.codemodel.JVar)

Example 29 with JMethod

use of com.sun.codemodel.JMethod in project rest.li by linkedin.

the class JavaDataTemplateGenerator method generatePathSpecNestedClass.

private JDefinedClass generatePathSpecNestedClass(JDefinedClass templateClass) throws JClassAlreadyExistsException {
    final JDefinedClass fieldsNestedClass = templateClass._class(JMod.PUBLIC | JMod.STATIC, "Fields");
    fieldsNestedClass._extends(_pathSpecClass);
    final JMethod constructor = fieldsNestedClass.constructor(JMod.PUBLIC);
    final JClass listString = getCodeModel().ref(List.class).narrow(String.class);
    final JVar namespace = constructor.param(listString, "path");
    final JVar name = constructor.param(String.class, "name");
    constructor.body().invoke(SUPER).arg(namespace).arg(name);
    fieldsNestedClass.constructor(JMod.PUBLIC).body().invoke(SUPER);
    return fieldsNestedClass;
}
Also used : JDefinedClass(com.sun.codemodel.JDefinedClass) JClass(com.sun.codemodel.JClass) List(java.util.List) JMethod(com.sun.codemodel.JMethod) JVar(com.sun.codemodel.JVar)

Example 30 with JMethod

use of com.sun.codemodel.JMethod in project rest.li by linkedin.

the class JavaRequestBuilderGenerator method generateOptions.

private void generateOptions(JDefinedClass facadeClass, JExpression baseUriExpr, JExpression requestOptionsExpr) {
    final JClass builderClass = getCodeModel().ref(OptionsRequestBuilder.class);
    final JMethod finderMethod = facadeClass.method(JMod.PUBLIC, OptionsRequestBuilder.class, "options");
    finderMethod.body()._return(JExpr._new(builderClass).arg(baseUriExpr).arg(requestOptionsExpr));
}
Also used : JClass(com.sun.codemodel.JClass) JMethod(com.sun.codemodel.JMethod)

Aggregations

JMethod (com.sun.codemodel.JMethod)62 JVar (com.sun.codemodel.JVar)40 JBlock (com.sun.codemodel.JBlock)26 JClass (com.sun.codemodel.JClass)21 JDefinedClass (com.sun.codemodel.JDefinedClass)17 JInvocation (com.sun.codemodel.JInvocation)15 JFieldVar (com.sun.codemodel.JFieldVar)11 JType (com.sun.codemodel.JType)10 JExpression (com.sun.codemodel.JExpression)9 Map (java.util.Map)7 JConditional (com.sun.codemodel.JConditional)6 HashMap (java.util.HashMap)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ArrayList (java.util.ArrayList)4 ByteString (com.linkedin.data.ByteString)2 DataList (com.linkedin.data.DataList)2 DataMap (com.linkedin.data.DataMap)2 ArrayDataSchema (com.linkedin.data.schema.ArrayDataSchema)2 DataSchema (com.linkedin.data.schema.DataSchema)2 EnumDataSchema (com.linkedin.data.schema.EnumDataSchema)2