use of com.helger.jcodemodel.JFieldVar in project androidannotations by androidannotations.
the class EBeanHolder method createFactoryMethod.
public void createFactoryMethod(boolean hasSingletonScope) {
AbstractJClass narrowedGeneratedClass = codeModelHelper.narrowGeneratedClass(generatedClass, annotatedElement.asType());
JMethod factoryMethod = generatedClass.method(PUBLIC | STATIC, narrowedGeneratedClass, GET_INSTANCE_METHOD_NAME);
codeModelHelper.generify(factoryMethod, annotatedElement);
JVar factoryMethodContextParam = factoryMethod.param(getClasses().CONTEXT, "context");
JBlock factoryMethodBody = factoryMethod.body();
/*
* Singletons are bound to the application context
*/
if (hasSingletonScope) {
JFieldVar instanceField = generatedClass.field(PRIVATE | STATIC, generatedClass, "instance" + generationSuffix());
JBlock creationBlock = //
factoryMethodBody._if(//
instanceField.eq(_null()))._then();
JVar previousNotifier = viewNotifierHelper.replacePreviousNotifierWithNull(creationBlock);
creationBlock.assign(instanceField, _new(narrowedGeneratedClass).arg(factoryMethodContextParam.invoke("getApplicationContext")));
creationBlock.invoke(instanceField, getInit());
viewNotifierHelper.resetPreviousNotifier(creationBlock, previousNotifier);
factoryMethodBody._return(instanceField);
} else {
factoryMethodBody._return(_new(narrowedGeneratedClass).arg(factoryMethodContextParam));
}
}
use of com.helger.jcodemodel.JFieldVar in project androidannotations by androidannotations.
the class EFragmentHolder method setFindViewById.
private void setFindViewById() {
JMethod findViewById = generatedClass.method(PUBLIC, getClasses().VIEW, "findViewById");
findViewById.annotate(Override.class);
JVar idParam = findViewById.param(getCodeModel().INT, "id");
JBlock body = findViewById.body();
JFieldVar contentView = getContentView();
//
body._if(contentView.eq(_null()))._then()._return(_null());
body._return(contentView.invoke(findViewById).arg(idParam));
}
use of com.helger.jcodemodel.JFieldVar in project RoboBinding by RoboBinding.
the class PresentationModelObjectClassGen method defineFields.
/**
* Note: not private in order to improve performance.
*
* final PresentationModelType presentationModel;
*/
@Override
public void defineFields() {
JFieldVar var = definedClass.field(JMod.FINAL, presentationModelClass, "presentationModel");
presentationModelField = JExpr.refthis(var.name());
presentationModelFieldWithoutThis = JExpr.ref(var.name());
}
use of com.helger.jcodemodel.JFieldVar in project RoboBinding by RoboBinding.
the class ItemPresentationModelObjectClassGen method defineFields.
/**
* Note: not private in order to improve performance.
*
* final ItemPresentationModelType itemPresentationModel;
*/
@Override
public void defineFields() {
JFieldVar var = definedClass.field(JMod.FINAL, presentationModelClass, "itemPresentationModel");
presentationModelField = JExpr.refthis(var.name());
presentationModelFieldWithoutThis = JExpr.ref(var.name());
}
use of com.helger.jcodemodel.JFieldVar in project RoboBinding by RoboBinding.
the class ViewBindingObjectClassGen method defineFields.
/**
* Note: not private in order to improve performance.
*
* final CustomViewBindingType customViewBinding;
*/
public void defineFields() {
JFieldVar var = definedClass.field(JMod.FINAL, customViewBindingClass, "customViewBinding");
customViewBindingField = JExpr.refthis(var.name());
customViewBindingFieldWithoutThis = JExpr.ref(var.name());
}
Aggregations