Search in sources :

Example 31 with JMethod

use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.

the class EActivityHolder method setOnConfigurationChanged.

private void setOnConfigurationChanged() {
    JMethod method = generatedClass.method(JMod.PUBLIC, getCodeModel().VOID, "onConfigurationChanged");
    method.annotate(Override.class);
    AbstractJClass configurationClass = getClasses().CONFIGURATION;
    onConfigurationChangedNewConfigParam = method.param(configurationClass, "newConfig");
    JBlock body = method.body();
    onConfigurationChangedBeforeSuperBlock = body.blockSimple();
    body.invoke(_super(), method).arg(onConfigurationChangedNewConfigParam);
    onConfigurationChangedAfterSuperBlock = body.blockSimple();
}
Also used : JBlock(com.helger.jcodemodel.JBlock) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JMethod(com.helger.jcodemodel.JMethod)

Example 32 with JMethod

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());
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 33 with JMethod

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));
    }
}
Also used : JFieldVar(com.helger.jcodemodel.JFieldVar) JBlock(com.helger.jcodemodel.JBlock) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 34 with JMethod

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();
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod)

Example 35 with JMethod

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));
}
Also used : JMethod(com.helger.jcodemodel.JMethod)

Aggregations

JMethod (com.helger.jcodemodel.JMethod)122 JBlock (com.helger.jcodemodel.JBlock)73 JVar (com.helger.jcodemodel.JVar)56 AbstractJClass (com.helger.jcodemodel.AbstractJClass)36 JInvocation (com.helger.jcodemodel.JInvocation)26 JDefinedClass (com.helger.jcodemodel.JDefinedClass)20 IJExpression (com.helger.jcodemodel.IJExpression)15 ExecutableElement (javax.lang.model.element.ExecutableElement)13 JFieldVar (com.helger.jcodemodel.JFieldVar)10 JConditional (com.helger.jcodemodel.JConditional)8 JTryBlock (com.helger.jcodemodel.JTryBlock)7 JTypeVar (com.helger.jcodemodel.JTypeVar)7 TypeMirror (javax.lang.model.type.TypeMirror)7 VariableElement (javax.lang.model.element.VariableElement)6 JFieldRef (com.helger.jcodemodel.JFieldRef)5 JPrimitiveType (com.helger.jcodemodel.JPrimitiveType)5 ArrayList (java.util.ArrayList)5 VisitorDefinition (com.github.sviperll.adt4j.model.config.VisitorDefinition)4 GenerationProcess (com.github.sviperll.adt4j.model.util.GenerationProcess)4 AbstractJType (com.helger.jcodemodel.AbstractJType)4