Search in sources :

Example 71 with AbstractJClass

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

the class EActivityHolder method setOnCreate.

private void setOnCreate() {
    onCreate = generatedClass.method(PUBLIC, getCodeModel().VOID, "onCreate");
    onCreate.annotate(Override.class);
    AbstractJClass bundleClass = getClasses().BUNDLE;
    JVar onCreateSavedInstanceState = onCreate.param(bundleClass, "savedInstanceState");
    JBlock onCreateBody = onCreate.body();
    JVar previousNotifier = viewNotifierHelper.replacePreviousNotifier(onCreateBody);
    onCreateBody.invoke(getInit()).arg(onCreateSavedInstanceState);
    onCreateBody.invoke(_super(), onCreate).arg(onCreateSavedInstanceState);
    viewNotifierHelper.resetPreviousNotifier(onCreateBody, previousNotifier);
}
Also used : JBlock(com.helger.jcodemodel.JBlock) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JVar(com.helger.jcodemodel.JVar)

Example 72 with AbstractJClass

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

the class RoboGuiceHandler method fireEvent.

private void fireEvent(JFieldVar eventManager, JBlock body, AbstractJClass eventClass, IJExpression... eventArguments) {
    AbstractJClass actualEventClass = eventClass;
    if (eventClass.fullName().startsWith("roboguice.context.event")) {
        actualEventClass = eventClass.narrow(getClasses().ACTIVITY);
    }
    JInvocation newEvent = _new(actualEventClass);
    newEvent.arg(_this());
    for (IJExpression eventArgument : eventArguments) {
        newEvent.arg(eventArgument);
    }
    body.invoke(eventManager, "fire").arg(newEvent);
}
Also used : IJExpression(com.helger.jcodemodel.IJExpression) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JInvocation(com.helger.jcodemodel.JInvocation)

Example 73 with AbstractJClass

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

the class RoboGuiceHolder method getScopedObjectsField.

public JFieldVar getScopedObjectsField() {
    if (scopedObjects == null) {
        AbstractJClass keyWildCard = getJClass(RoboGuiceClasses.KEY).narrow(getCodeModel().wildcard());
        AbstractJClass scopedHashMap = environment().getClasses().HASH_MAP.narrow(keyWildCard, environment().getClasses().OBJECT);
        scopedObjects = getGeneratedClass().field(JMod.PROTECTED, scopedHashMap, "scopedObjects" + generationSuffix());
        scopedObjects.assign(JExpr._new(scopedHashMap));
    }
    return scopedObjects;
}
Also used : AbstractJClass(com.helger.jcodemodel.AbstractJClass)

Example 74 with AbstractJClass

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

Example 75 with AbstractJClass

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

the class RestHolder method setRestErrorHandlerField.

private void setRestErrorHandlerField() {
    AbstractJClass restErrorHandlerClass = getJClass(RestErrorHandler.class.getName());
    restErrorHandlerField = getGeneratedClass().field(JMod.PRIVATE, restErrorHandlerClass, "restErrorHandler");
}
Also used : RestErrorHandler(org.androidannotations.rest.spring.api.RestErrorHandler) AbstractJClass(com.helger.jcodemodel.AbstractJClass)

Aggregations

AbstractJClass (com.helger.jcodemodel.AbstractJClass)125 JVar (com.helger.jcodemodel.JVar)48 JMethod (com.helger.jcodemodel.JMethod)36 JBlock (com.helger.jcodemodel.JBlock)35 JInvocation (com.helger.jcodemodel.JInvocation)31 TypeMirror (javax.lang.model.type.TypeMirror)24 IJExpression (com.helger.jcodemodel.IJExpression)23 JDefinedClass (com.helger.jcodemodel.JDefinedClass)19 VariableElement (javax.lang.model.element.VariableElement)14 JFieldVar (com.helger.jcodemodel.JFieldVar)13 GenerationProcess (com.github.sviperll.adt4j.model.util.GenerationProcess)9 ExecutableElement (javax.lang.model.element.ExecutableElement)9 JAnnotationUse (com.helger.jcodemodel.JAnnotationUse)8 JConditional (com.helger.jcodemodel.JConditional)8 JTypeVar (com.helger.jcodemodel.JTypeVar)8 DeclaredType (javax.lang.model.type.DeclaredType)8 VisitorDefinition (com.github.sviperll.adt4j.model.config.VisitorDefinition)6 JFieldRef (com.helger.jcodemodel.JFieldRef)6 ArrayList (java.util.ArrayList)6 BundleHelper (org.androidannotations.helper.BundleHelper)6