Search in sources :

Example 6 with JVar

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

the class KeyEventCallbackMethodsDelegate method createOnKeyMultipleMethod.

private void createOnKeyMultipleMethod() {
    JMethod method = getGeneratedClass().method(PUBLIC, codeModel().BOOLEAN, "onKeyMultiple");
    method.annotate(Override.class);
    JVar keyCode = method.param(codeModel().INT, "keyCode");
    onKeyMultipleCountParam = method.param(codeModel().INT, "count");
    onKeyMultipleKeyEventParam = method.param(getClasses().KEY_EVENT, "keyEvent");
    JBlock methodBody = method.body();
    onKeyMultipleSwitchBody = methodBody._switch(keyCode);
    methodBody._return(_super().invoke(method).arg(keyCode).arg(onKeyMultipleCountParam).arg(onKeyDownKeyEventParam));
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 7 with JVar

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

the class KeyEventCallbackMethodsDelegate method createOnKeyDownMethod.

private void createOnKeyDownMethod() {
    JMethod method = getGeneratedClass().method(PUBLIC, codeModel().BOOLEAN, "onKeyDown");
    method.annotate(Override.class);
    JVar keyCode = method.param(codeModel().INT, "keyCode");
    onKeyDownKeyEventParam = method.param(getClasses().KEY_EVENT, "keyEvent");
    JBlock methodBody = method.body();
    onKeyDownSwitchBody = methodBody._switch(keyCode);
    methodBody._return(_super().invoke(method).arg(keyCode).arg(onKeyDownKeyEventParam));
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 8 with JVar

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

the class APTCodeModelHelper method copy.

public void copy(JBlock body, JBlock newBody) {
    for (Object statement : body.getContents()) {
        if (statement instanceof JVar) {
            JVar var = (JVar) statement;
            try {
                Field varInitField = JVar.class.getDeclaredField("m_aInitExpr");
                varInitField.setAccessible(true);
                IJExpression varInit = (IJExpression) varInitField.get(var);
                newBody.decl(var.type(), var.name(), varInit);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        } else {
            newBody.add((IJStatement) statement);
        }
    }
}
Also used : Field(java.lang.reflect.Field) IJExpression(com.helger.jcodemodel.IJExpression) JVar(com.helger.jcodemodel.JVar)

Example 9 with JVar

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

the class EActivityHolder method setContentViewMethod.

private JMethod setContentViewMethod(AbstractJType[] paramTypes, String[] paramNames) {
    JMethod method = generatedClass.method(JMod.PUBLIC, getCodeModel().VOID, "setContentView");
    method.annotate(Override.class);
    List<JVar> params = new ArrayList<>();
    for (int i = 0; i < paramTypes.length; i++) {
        JVar param = method.param(paramTypes[i], paramNames[i]);
        params.add(param);
    }
    JBlock body = method.body();
    JInvocation superCall = body.invoke(JExpr._super(), method);
    for (JVar arg : params) {
        superCall.arg(arg);
    }
    viewNotifierHelper.invokeViewChanged(body);
    return method;
}
Also used : ArrayList(java.util.ArrayList) JBlock(com.helger.jcodemodel.JBlock) JInvocation(com.helger.jcodemodel.JInvocation) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 10 with JVar

use of com.helger.jcodemodel.JVar 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)

Aggregations

JVar (com.helger.jcodemodel.JVar)119 JBlock (com.helger.jcodemodel.JBlock)81 JMethod (com.helger.jcodemodel.JMethod)56 AbstractJClass (com.helger.jcodemodel.AbstractJClass)48 JInvocation (com.helger.jcodemodel.JInvocation)38 IJExpression (com.helger.jcodemodel.IJExpression)32 VariableElement (javax.lang.model.element.VariableElement)25 ExecutableElement (javax.lang.model.element.ExecutableElement)18 TypeMirror (javax.lang.model.type.TypeMirror)16 JDefinedClass (com.helger.jcodemodel.JDefinedClass)15 JFieldRef (com.helger.jcodemodel.JFieldRef)15 JFieldVar (com.helger.jcodemodel.JFieldVar)12 JConditional (com.helger.jcodemodel.JConditional)9 JTryBlock (com.helger.jcodemodel.JTryBlock)7 JCatchBlock (com.helger.jcodemodel.JCatchBlock)5 AbstractJType (com.helger.jcodemodel.AbstractJType)4 ArrayList (java.util.ArrayList)4 BundleHelper (org.androidannotations.helper.BundleHelper)4 JTypeVar (com.helger.jcodemodel.JTypeVar)3 PageChangeHolder (org.androidannotations.holder.PageChangeHolder)3