use of com.helger.jcodemodel.JSwitch in project androidannotations by androidannotations.
the class AbstractKeyEventHandler method process.
@Override
public void process(Element element, HasKeyEventCallbackMethods holder) throws Exception {
String methodName = element.getSimpleName().toString();
ExecutableElement executableElement = (ExecutableElement) element;
TypeMirror returnType = executableElement.getReturnType();
boolean returnMethodResult = returnType.getKind() != TypeKind.VOID;
JSwitch switchBody = getSwitchBody(holder);
int[] keyCodes = annotationHelper.extractKeyCode(element);
for (int keyCode : keyCodes) {
String keyCodeFieldName = annotationHelper.getFieldNameForKeyCode(keyCode);
JBlock switchCaseBody = switchBody._case(getClasses().KEY_EVENT.staticRef(keyCodeFieldName)).body();
JInvocation methodCall = invoke(methodName);
if (returnMethodResult) {
switchCaseBody._return(methodCall);
} else {
switchCaseBody.add(methodCall);
switchCaseBody._return(TRUE);
}
passParametersToMethodCall(element, holder, methodCall);
}
}
Aggregations