use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class AbstractViewListenerHandler method assignListeners.
@Override
protected final void assignListeners(EComponentWithViewSupportHolder holder, List<JFieldRef> idsRefs, JDefinedClass listenerAnonymousClass) {
for (JFieldRef idRef : idsRefs) {
AbstractJClass listenerTargetClass = getListenerTargetClass(holder);
FoundViewHolder foundViewHolder = holder.getFoundViewHolder(idRef, listenerTargetClass);
foundViewHolder.getIfNotNullBlock().invoke(foundViewHolder.getOrCastRef(listenerTargetClass), getSetterName()).arg(_new(listenerAnonymousClass));
}
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class ExtraParameterHandler method getExtraValue.
public IJExpression getExtraValue(VariableElement parameter, JVar extras, JBlock block, JMethod annotatedMethod, JDefinedClass generatedClass) {
String parameterName = parameter.getSimpleName().toString();
AbstractJClass parameterClass = codeModelHelper.typeMirrorToJClass(parameter.asType());
String extraKey = getAnnotationValue(parameter);
if (extraKey == null || extraKey.isEmpty()) {
extraKey = parameterName;
}
BundleHelper bundleHelper = new BundleHelper(getEnvironment(), parameter.asType());
IJExpression restoreMethodCall = bundleHelper.getExpressionToRestoreFromBundle(parameterClass, extras, getStaticExtraField(generatedClass, extraKey), annotatedMethod);
return block.decl(parameterClass, parameterName, restoreMethodCall);
}
use of com.helger.jcodemodel.AbstractJClass 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());
}
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class EFragmentHolder method setFragmentBuilder.
private void setFragmentBuilder() throws JClassAlreadyExistsException {
fragmentBuilderClass = generatedClass._class(PUBLIC | STATIC, "FragmentBuilder" + generationSuffix());
narrowBuilderClass = narrow(fragmentBuilderClass);
codeModelHelper.generify(fragmentBuilderClass, annotatedElement);
AbstractJClass superClass = getJClass(org.androidannotations.api.builder.FragmentBuilder.class);
superClass = superClass.narrow(narrowBuilderClass, getAnnotatedClass());
fragmentBuilderClass._extends(superClass);
fragmentArgumentsBuilderField = ref("args");
setFragmentBuilderBuild();
setFragmentBuilderCreate();
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class EFragmentHolder method setFragmentBuilderBuild.
private void setFragmentBuilderBuild() {
JMethod method = fragmentBuilderClass.method(PUBLIC, generatedClass._extends(), "build");
method.annotate(Override.class);
JBlock body = method.body();
AbstractJClass result = narrow(generatedClass);
JVar fragment = body.decl(result, "fragment_", _new(result));
body.invoke(fragment, "setArguments").arg(fragmentArgumentsBuilderField);
body._return(fragment);
}
Aggregations