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);
}
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));
}
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);
}
}
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;
}
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));
}
Aggregations