Search in sources :

Example 46 with JInvocation

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

the class EReceiverHolder method setOnReceiveIntentDataScheme.

private void setOnReceiveIntentDataScheme() {
    JInvocation getDataSchemeInvocation = JExpr.invoke(getOnReceiveIntent(), "getScheme");
    onReceiveIntentDataScheme = getOnReceiveBody().decl(getClasses().STRING, "dataScheme", getDataSchemeInvocation);
}
Also used : JInvocation(com.helger.jcodemodel.JInvocation)

Example 47 with JInvocation

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

the class EReceiverHolder method setOnReceiveIntentAction.

private void setOnReceiveIntentAction() {
    JInvocation getActionInvocation = JExpr.invoke(getOnReceiveIntent(), "getAction");
    onReceiveIntentAction = getOnReceiveBody().decl(getClasses().STRING, "action", getActionInvocation);
}
Also used : JInvocation(com.helger.jcodemodel.JInvocation)

Example 48 with JInvocation

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

the class EViewHolder method createConstructorAndBuilder.

private void createConstructorAndBuilder() {
    List<ExecutableElement> constructors = new ArrayList<>();
    for (Element e : annotatedElement.getEnclosedElements()) {
        if (e.getKind() == CONSTRUCTOR) {
            constructors.add((ExecutableElement) e);
        }
    }
    for (ExecutableElement userConstructor : constructors) {
        JMethod copyConstructor = generatedClass.constructor(PUBLIC);
        JMethod staticHelper = generatedClass.method(PUBLIC | STATIC, generatedClass._extends(), "build");
        codeModelHelper.generify(staticHelper, getAnnotatedElement());
        JBlock body = copyConstructor.body();
        JInvocation superCall = body.invoke("super");
        AbstractJClass narrowedGeneratedClass = narrow(generatedClass);
        JInvocation newInvocation = JExpr._new(narrowedGeneratedClass);
        for (VariableElement param : userConstructor.getParameters()) {
            String paramName = param.getSimpleName().toString();
            AbstractJClass paramType = codeModelHelper.typeMirrorToJClass(param.asType());
            copyConstructor.param(paramType, paramName);
            staticHelper.param(paramType, paramName);
            superCall.arg(JExpr.ref(paramName));
            newInvocation.arg(JExpr.ref(paramName));
        }
        JVar newCall = staticHelper.body().decl(narrowedGeneratedClass, "instance", newInvocation);
        staticHelper.body().invoke(newCall, getOnFinishInflate());
        staticHelper.body()._return(newCall);
        body.invoke(getInit());
    }
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ExecutableElement(javax.lang.model.element.ExecutableElement) VariableElement(javax.lang.model.element.VariableElement) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement) ArrayList(java.util.ArrayList) JBlock(com.helger.jcodemodel.JBlock) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JInvocation(com.helger.jcodemodel.JInvocation) VariableElement(javax.lang.model.element.VariableElement) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 49 with JInvocation

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

the class PreferencesDelegate method findPreferenceByKey.

private JInvocation findPreferenceByKey(JFieldRef idRef) {
    JInvocation getString = invoke(_this(), "getString").arg(idRef);
    JInvocation findPreferenceByKey = invoke(_this(), "findPreference");
    return findPreferenceByKey.arg(getString);
}
Also used : JInvocation(com.helger.jcodemodel.JInvocation)

Example 50 with JInvocation

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

the class EIntentServiceHolder method createOnHandleIntent.

private void createOnHandleIntent() {
    onHandleIntentMethod = generatedClass.method(PUBLIC, getCodeModel().VOID, "onHandleIntent");
    onHandleIntentIntent = onHandleIntentMethod.param(getClasses().INTENT, "intent");
    onHandleIntentMethod.annotate(Override.class);
    onHandleIntentBody = onHandleIntentMethod.body();
    codeModelHelper.callSuperMethod(onHandleIntentMethod, this, onHandleIntentBody);
    JInvocation getActionInvocation = JExpr.invoke(onHandleIntentIntent, "getAction");
    onHandleIntentIntentAction = onHandleIntentBody.decl(getClasses().STRING, "action", getActionInvocation);
}
Also used : JInvocation(com.helger.jcodemodel.JInvocation)

Aggregations

JInvocation (com.helger.jcodemodel.JInvocation)71 JVar (com.helger.jcodemodel.JVar)38 JBlock (com.helger.jcodemodel.JBlock)37 AbstractJClass (com.helger.jcodemodel.AbstractJClass)31 IJExpression (com.helger.jcodemodel.IJExpression)27 JMethod (com.helger.jcodemodel.JMethod)26 ExecutableElement (javax.lang.model.element.ExecutableElement)20 VariableElement (javax.lang.model.element.VariableElement)16 JFieldRef (com.helger.jcodemodel.JFieldRef)14 TypeMirror (javax.lang.model.type.TypeMirror)14 JConditional (com.helger.jcodemodel.JConditional)11 JDefinedClass (com.helger.jcodemodel.JDefinedClass)9 AbstractJType (com.helger.jcodemodel.AbstractJType)5 JFieldVar (com.helger.jcodemodel.JFieldVar)5 JTryBlock (com.helger.jcodemodel.JTryBlock)5 ArrayList (java.util.ArrayList)4 DeclaredType (javax.lang.model.type.DeclaredType)4 JCatchBlock (com.helger.jcodemodel.JCatchBlock)3 PageChangeHolder (org.androidannotations.holder.PageChangeHolder)3 TextWatcherHolder (org.androidannotations.holder.TextWatcherHolder)3