use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class AbstractOttoHandler method process.
@Override
public void process(Element element, EComponentHolder holder) throws Exception {
if (!annotationHelper.enclosingElementHasEnhancedComponentAnnotation(element)) {
// do nothing when otto annotations are used in non-enhanced classes
return;
}
ExecutableElement executableElement = (ExecutableElement) element;
JMethod method = codeModelHelper.overrideAnnotatedMethod(executableElement, holder);
addOttoAnnotation(executableElement, method);
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class RoboGuiceHandler method onDestroyMethod.
private void onDestroyMethod(EActivityHolder holder, JFieldVar eventManager) {
JBlock onDestroyBlock = new JBlock().bracesRequired(false).indentRequired(false);
JTryBlock tryBlock = onDestroyBlock._try();
fireEvent(eventManager, tryBlock.body(), getJClass(RoboGuiceClasses.ON_DESTROY_EVENT));
JBlock finallyBody = tryBlock._finally();
JTryBlock tryInFinally = finallyBody._try();
tryInFinally.body().add(getJClass(RoboGuiceClasses.ROBO_GUICE).staticInvoke("destroyInjector").arg(_this()));
tryInFinally._finally().invoke(_super(), "onDestroy");
JMethod onDestroy = holder.getOnDestroy();
codeModelHelper.replaceSuperCall(onDestroy, onDestroyBlock);
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class RoboGuiceHandler method onStopMethod.
private void onStopMethod(EActivityHolder holder, JFieldVar eventManager) {
JBlock onStopBlock = new JBlock().bracesRequired(false).indentRequired(false);
JTryBlock tryBlock = onStopBlock._try();
fireEvent(eventManager, tryBlock.body(), getJClass(RoboGuiceClasses.ON_STOP_EVENT));
JBlock finallyBody = tryBlock._finally();
finallyBody.invoke(_super(), "onStop");
JMethod onStop = holder.getOnStop();
codeModelHelper.replaceSuperCall(onStop, onStopBlock);
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class IntentBuilder method addPutExtraMethod.
private JMethod addPutExtraMethod(Element element, List<IntentExtra> intentExtras) {
String docComment = elementUtils.getDocComment(element);
JMethod method = holder.getIntentBuilderClass().method(PUBLIC, holder.getIntentBuilderClass(), element.getSimpleName().toString());
method.javadoc().addReturn().append("the IntentBuilder to chain calls");
codeModelHelper.addTrimmedDocComment(method, docComment);
int paramCount = intentExtras.size();
for (int i = 0; i < paramCount; i++) {
IntentExtra intentExtra = intentExtras.get(i);
method.javadoc().addParam(intentExtra.parameterName).append("the value for this extra");
AbstractJClass parameterClass = codeModelHelper.typeMirrorToJClass(intentExtra.type);
JVar extraParameterVar = method.param(parameterClass, intentExtra.parameterName);
JInvocation superCall = getSuperPutExtraInvocation(intentExtra.type, extraParameterVar, intentExtra.keyField);
if (i + 1 == paramCount) {
method.body()._return(superCall);
} else {
method.body().add(superCall);
}
}
return method;
}
use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.
the class IntentBuilder method createContextConstructor.
private void createContextConstructor() {
IJExpression generatedClass = holder.getGeneratedClass().dotclass();
JMethod constructor = holder.getIntentBuilderClass().constructor(JMod.PUBLIC);
JVar constructorContextParam = constructor.param(getClasses().CONTEXT, "context");
constructor.body().invoke("super").arg(constructorContextParam).arg(generatedClass);
}
Aggregations