use of com.helger.jcodemodel.IJExpression in project androidannotations by androidannotations.
the class ReceiverRegistrationDelegate method createIntentFilterField.
private JFieldVar createIntentFilterField(IntentFilterData intentFilterData) {
String intentFilterName = "intentFilter" + (intentFilterFields.size() + 1) + generationSuffix();
IJExpression newIntentFilterExpr = _new(getClasses().INTENT_FILTER);
JFieldVar intentFilterField = getGeneratedClass().field(PRIVATE | FINAL, getClasses().INTENT_FILTER, intentFilterName, newIntentFilterExpr);
JBlock intentFilterTarget = holder.getIntentFilterInitializationBlock(intentFilterData);
for (String action : intentFilterData.getActionSet()) {
intentFilterTarget.invoke(intentFilterField, "addAction").arg(action);
}
for (String dataScheme : intentFilterData.getDataSchemeSet()) {
intentFilterTarget.invoke(intentFilterField, "addDataScheme").arg(dataScheme);
}
return intentFilterField;
}
use of com.helger.jcodemodel.IJExpression in project androidannotations by androidannotations.
the class AbstractResHandler method assignValue.
@Override
public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EComponentHolder holder, Element element, Element param) {
IRClass.Res resInnerClass = androidRes.getRInnerClass();
JFieldRef idRef = annotationHelper.extractOneAnnotationFieldRef(element, resInnerClass, true);
IJExpression resourceInstance = getInstanceInvocation(holder, idRef, fieldRef, targetBlock);
if (resourceInstance != null) {
targetBlock.add(fieldRef.assign(resourceInstance));
}
}
use of com.helger.jcodemodel.IJExpression 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.IJExpression in project androidannotations by androidannotations.
the class PreferencesDelegate method createFoundPreferenceAndIfNotNullBlock.
private FoundPreferenceHolder createFoundPreferenceAndIfNotNullBlock(JFieldRef idRef, AbstractJClass preferenceClass, IJAssignmentTarget fieldRef) {
IJExpression findPreferenceExpression = findPreferenceByKey(idRef);
JBlock block = getAddPreferencesFromResourceInjectionBlock();
if (preferenceClass == null) {
preferenceClass = basePreferenceClass;
} else if (!preferenceClass.equals(basePreferenceClass)) {
findPreferenceExpression = cast(preferenceClass, findPreferenceExpression);
}
IJAssignmentTarget foundPref = fieldRef;
if (foundPref == null) {
foundPref = block.decl(preferenceClass, "preference_" + idRef.name(), findPreferenceExpression);
} else {
block.add(foundPref.assign(findPreferenceExpression));
}
return new FoundPreferenceHolder(this, preferenceClass, foundPref, block);
}
Aggregations