Search in sources :

Example 76 with JMethod

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

the class EActivityHolder method setOnOptionsItemSelected.

private void setOnOptionsItemSelected() {
    JMethod method = generatedClass.method(JMod.PUBLIC, getCodeModel().BOOLEAN, "onOptionsItemSelected");
    method.annotate(Override.class);
    JBlock methodBody = method.body();
    onOptionsItemSelectedItem = method.param(getClasses().MENU_ITEM, "item");
    onOptionsItemSelectedItemId = methodBody.decl(getCodeModel().INT, "itemId_", onOptionsItemSelectedItem.invoke("getItemId"));
    onOptionsItemSelectedMiddleBlock = methodBody.blockSimple();
    methodBody._return(invoke(_super(), method).arg(onOptionsItemSelectedItem));
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod)

Example 77 with JMethod

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

the class EActivityHolder method setFindNativeFragmentByTag.

@Override
protected void setFindNativeFragmentByTag() {
    JMethod method = generatedClass.method(PRIVATE, getClasses().FRAGMENT, "findNativeFragmentByTag");
    JVar tagParam = method.param(getClasses().STRING, "tag");
    JBlock body = method.body();
    body._return(invoke("getFragmentManager").invoke("findFragmentByTag").arg(tagParam));
    findNativeFragmentByTag = method;
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 78 with JMethod

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

the class EApplicationHolder method createOnCreate.

private void createOnCreate() {
    JMethod onCreate = generatedClass.method(PUBLIC, getCodeModel().VOID, "onCreate");
    onCreate.annotate(Override.class);
    JBlock onCreateBody = onCreate.body();
    onCreateBody.assign(staticInstanceField, _this());
    onCreateBody.invoke(getInit());
    onCreateBody.invoke(_super(), onCreate);
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod)

Example 79 with JMethod

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

the class RoboGuiceHandler method getScopedObjectMap.

private void getScopedObjectMap(EActivityHolder holder, JFieldVar scopedObjectMap) {
    JMethod getScopedObjectMapMethod = holder.getGeneratedClass().method(JMod.PUBLIC, scopedObjectMap.type(), "getScopedObjectMap");
    getScopedObjectMapMethod.annotate(Override.class);
    getScopedObjectMapMethod.body()._return(scopedObjectMap);
}
Also used : JMethod(com.helger.jcodemodel.JMethod)

Example 80 with JMethod

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

the class RestHolder method implementSetBearerAuth.

private void implementSetBearerAuth(List<ExecutableElement> methods) {
    JMethod setBearerMethod = codeModelHelper.implementMethod(this, methods, "setBearerAuth", TypeKind.VOID.toString(), true, STRING);
    if (setBearerMethod != null) {
        JVar tokenParamVar = setBearerMethod.params().get(0);
        IJExpression tokenExpr = lit("Bearer ").plus(tokenParamVar);
        AbstractJClass authClass = getJClass(HTTP_AUTHENTICATION);
        JDefinedClass anonymousHttpAuthClass = getCodeModel().anonymousClass(authClass);
        JMethod getHeaderValueMethod = anonymousHttpAuthClass.method(JMod.PUBLIC, String.class, "getHeaderValue");
        getHeaderValueMethod.annotate(Override.class);
        JBlock getHeaderValueMethodBody = getHeaderValueMethod.body();
        getHeaderValueMethodBody._return(tokenExpr);
        JBlock setBearerBody = setBearerMethod.body();
        setBearerBody.assign(_this().ref(getAuthenticationField()), _new(anonymousHttpAuthClass));
    }
}
Also used : JDefinedClass(com.helger.jcodemodel.JDefinedClass) IJExpression(com.helger.jcodemodel.IJExpression) JBlock(com.helger.jcodemodel.JBlock) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

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