use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EBeanHolder method createRebindMethod.
public void createRebindMethod() {
JMethod rebindMethod = generatedClass.method(PUBLIC, getCodeModel().VOID, "rebind");
JVar contextParam = rebindMethod.param(getClasses().CONTEXT, "context");
JBlock body = rebindMethod.body();
body.assign(getContextField(), contextParam);
body.invoke(getInit());
}
use of com.helger.jcodemodel.JMethod 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.JMethod in project androidannotations by androidannotations.
the class EFragmentHolder method setOnResume.
private void setOnResume() {
JMethod onResume = generatedClass.method(PUBLIC, getCodeModel().VOID, "onResume");
onResume.annotate(Override.class);
JBlock onResumeBody = onResume.body();
onResumeBody.invoke(_super(), onResume);
onResumeAfterSuperBlock = onResumeBody.blockSimple();
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EFragmentHolder method setFragmentBuilderCreate.
private void setFragmentBuilderCreate() {
JMethod method = generatedClass.method(STATIC | PUBLIC, narrowBuilderClass, "builder");
codeModelHelper.generify(method, annotatedElement);
method.body()._return(_new(narrowBuilderClass));
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class EFragmentHolder method setOnAttach.
private void setOnAttach() {
JMethod onAttach = generatedClass.method(PUBLIC, getCodeModel().VOID, "onAttach");
onAttach.annotate(Override.class);
JVar activityParam = onAttach.param(getClasses().ACTIVITY, "activity");
JBlock onAttachBody = onAttach.body();
onAttachBody.invoke(_super(), onAttach).arg(activityParam);
onAttachAfterSuperBlock = onAttachBody.blockSimple();
}
Aggregations