use of com.helger.jcodemodel.AbstractJClass in project RoboBinding by RoboBinding.
the class ViewBindingObjectClassGen method defineMapBindingAttributesMethod.
/**
*
@Override
public void mapBindingAttributes(BindingAttributeMappings<ImageView> mappings) {
mappings.mapOneWayProperty(ImageAlphaAttribute.class, "imageAlpha");
mappings.mapOneWayProperty(MaxWidthAttribute.class, "maxWidth");
mappings.mapOneWayProperty(MaxHeightAttribute.class, "maxHeight");
customViewBinding.mapBindingAttributes(mappings);
}
*
*/
public void defineMapBindingAttributesMethod() {
JMethod method = definedClass.method(JMod.PUBLIC, codeModel.VOID, "mapBindingAttributes");
method.annotate(Override.class);
AbstractJClass bindingAttributeMappingsType = codeModel.ref(BindingAttributeMappings.class).narrow(viewClass);
JVar mappingsParam = method.param(bindingAttributeMappingsType, "mappings");
JBlock body = method.body();
for (SimpleOneWayPropertyInfo info : simpleOneWayPropertyInfoList) {
body.invoke(mappingsParam, "mapOneWayProperty").arg(info.getBindingClass().dotclass()).arg(info.propertyName());
}
body.invoke(customViewBindingFieldWithoutThis, "mapBindingAttributes").arg(mappingsParam);
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class AbstractListenerHandler method castArgumentIfNecessary.
protected final IJExpression castArgumentIfNecessary(T holder, String baseType, JVar param, Element element) {
IJExpression argument = param;
TypeMirror typeMirror = element.asType();
if (!baseType.equals(typeMirror.toString())) {
AbstractJClass typeMirrorToJClass = codeModelHelper.typeMirrorToJClass(typeMirror);
argument = JExpr.cast(typeMirrorToJClass, param);
}
return argument;
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class AppHandler method assignValue.
@Override
public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EComponentHolder holder, Element element, Element param) {
String applicationQualifiedName = param.asType().toString();
AbstractJClass applicationClass = getJClass(applicationQualifiedName + classSuffix());
targetBlock.add(fieldRef.assign(applicationClass.staticInvoke(EApplicationHolder.GET_APPLICATION_INSTANCE)));
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class BackgroundHandler method process.
@Override
public void process(Element element, EComponentHolder holder) throws Exception {
ExecutableElement executableElement = (ExecutableElement) element;
JMethod delegatingMethod = codeModelHelper.overrideAnnotatedMethod(executableElement, holder);
JBlock previousMethodBody = codeModelHelper.removeBody(delegatingMethod);
JDefinedClass anonymousTaskClass = getCodeModel().anonymousClass(BackgroundExecutor.Task.class);
JMethod executeMethod = anonymousTaskClass.method(JMod.PUBLIC, getCodeModel().VOID, "execute");
executeMethod.annotate(Override.class);
// Catch exception in user code
JTryBlock tryBlock = executeMethod.body()._try();
tryBlock.body().add(previousMethodBody);
JCatchBlock catchBlock = tryBlock._catch(getClasses().THROWABLE);
JVar caughtException = catchBlock.param("e");
IJStatement uncaughtExceptionCall = //
getClasses().THREAD.staticInvoke(//
"getDefaultUncaughtExceptionHandler").invoke(//
"uncaughtException").arg(//
getClasses().THREAD.staticInvoke("currentThread")).arg(caughtException);
catchBlock.body().add(uncaughtExceptionCall);
Background annotation = element.getAnnotation(Background.class);
String id = annotation.id();
long delay = annotation.delay();
String serial = annotation.serial();
AbstractJClass backgroundExecutorClass = getJClass(BackgroundExecutor.class);
JInvocation newTask = _new(anonymousTaskClass).arg(lit(id)).arg(lit(delay)).arg(lit(serial));
JInvocation executeCall = backgroundExecutorClass.staticInvoke("execute").arg(newTask);
delegatingMethod.body().add(executeCall);
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class SharedPrefHolder method createEditorFieldMethods.
public void createEditorFieldMethods(ExecutableElement method, IJExpression keyExpression) {
String returnType = method.getReturnType().toString();
EditorFieldHolder editorFieldHolder = EDITOR_FIELD_BY_TYPE.get(returnType);
AbstractJClass editorFieldClass = getJClass(editorFieldHolder.fieldClass);
String fieldName = method.getSimpleName().toString();
JMethod editorFieldMethod = editorClass.method(PUBLIC, editorFieldClass.narrow(editorClass), fieldName);
String docComment = getProcessingEnvironment().getElementUtils().getDocComment(method);
codeModelHelper.addTrimmedDocComment(editorFieldMethod, docComment);
editorFieldMethod.body()._return(JExpr.invoke(editorFieldHolder.fieldMethodName).arg(keyExpression));
}
Aggregations