io.joynr.generator.interfaces.InterfaceAsyncTemplate Maven / Gradle / Ivy
The newest version!
package io.joynr.generator.interfaces;
import com.google.common.base.Objects;
import com.google.inject.Inject;
import io.joynr.generator.templates.InterfaceTemplate;
import io.joynr.generator.templates.util.AttributeUtil;
import io.joynr.generator.templates.util.InterfaceUtil;
import io.joynr.generator.templates.util.MethodUtil;
import io.joynr.generator.templates.util.NamingUtil;
import io.joynr.generator.util.JavaTypeUtil;
import io.joynr.generator.util.JoynrJavaGeneratorExtensions;
import io.joynr.generator.util.TemplateBase;
import java.util.ArrayList;
import java.util.HashMap;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.ExclusiveRange;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.franca.core.franca.FArgument;
import org.franca.core.franca.FAttribute;
import org.franca.core.franca.FEnumerationType;
import org.franca.core.franca.FInterface;
import org.franca.core.franca.FMethod;
@SuppressWarnings("all")
public class InterfaceAsyncTemplate extends InterfaceTemplate {
@Inject
@Extension
private JoynrJavaGeneratorExtensions _joynrJavaGeneratorExtensions;
@Inject
@Extension
private JavaTypeUtil _javaTypeUtil;
@Inject
@Extension
private InterfaceUtil _interfaceUtil;
@Inject
@Extension
private MethodUtil _methodUtil;
@Inject
@Extension
private NamingUtil _namingUtil;
@Inject
@Extension
private AttributeUtil _attributeUtil;
@Inject
@Extension
private TemplateBase _templateBase;
public void init(final FInterface serviceInterface, final HashMap methodToCallbackName, final HashMap methodToFutureName, final HashMap methodToErrorEnumName, final HashMap methodToSyncReturnedName, final ArrayList uniqueMultioutMethods, final boolean generateVersion) {
final String packagePath = this._joynrJavaGeneratorExtensions.getPackagePathWithJoynrPrefix(serviceInterface, ".", generateVersion);
HashMap uniqueMultioutMethodSignatureToOutputContainerName = new HashMap();
HashMap methodCounts = this._methodUtil.overloadedMethodCounts(this._interfaceUtil.getMethods(serviceInterface));
HashMap indexForMethod = new HashMap();
EList _methods = this._interfaceUtil.getMethods(serviceInterface);
for (final FMethod method : _methods) {
int _size = IterableExtensions.size(this._methodUtil.getOutputParameters(method));
boolean _lessThan = (_size < 2);
if (_lessThan) {
final String outputParamterType = this._javaTypeUtil.getTypeNamesForOutputParameter(method).iterator().next();
String _xifexpression = null;
boolean _equals = Objects.equal(outputParamterType, "void");
if (_equals) {
_xifexpression = "Void";
} else {
_xifexpression = this._javaTypeUtil.getObjectDataTypeForPlainType(outputParamterType);
}
String outputType = _xifexpression;
boolean _hasErrorEnum = this._methodUtil.hasErrorEnum(method);
if (_hasErrorEnum) {
String errorEnumType = "";
FEnumerationType _errors = method.getErrors();
boolean _tripleNotEquals = (_errors != null);
if (_tripleNotEquals) {
String _joynrName = this._namingUtil.joynrName(serviceInterface);
String _plus = ((packagePath + ".") + _joynrName);
String _plus_1 = (_plus + ".");
String _get = methodToErrorEnumName.get(method);
String _plus_2 = (_plus_1 + _get);
errorEnumType = _plus_2;
} else {
String _buildPackagePath = this._joynrJavaGeneratorExtensions.buildPackagePath(method.getErrorEnum(), ".", true, generateVersion);
String _plus_3 = (_buildPackagePath + ".");
String _joynrName_1 = this._namingUtil.joynrName(method.getErrorEnum());
String _plus_4 = (_plus_3 + _joynrName_1);
errorEnumType = _plus_4;
}
methodToCallbackName.put(method, (((("CallbackWithModeledError<" + outputType) + ",") + errorEnumType) + ">"));
} else {
methodToCallbackName.put(method, (("Callback<" + outputType) + ">"));
}
methodToFutureName.put(method, (("Future<" + outputType) + ">"));
methodToSyncReturnedName.put(method, outputType);
} else {
String callbackName = StringExtensions.toFirstUpper(method.getName());
String futureName = StringExtensions.toFirstUpper(method.getName());
String syncReturnedName = StringExtensions.toFirstUpper(method.getName());
Integer _get_1 = methodCounts.get(method.getName());
boolean _equals_1 = ((_get_1).intValue() == 1);
if (_equals_1) {
uniqueMultioutMethods.add(method);
String _callbackName = callbackName;
callbackName = (_callbackName + "Callback");
String _futureName = futureName;
futureName = (_futureName + "Future");
String _syncReturnedName = syncReturnedName;
syncReturnedName = (_syncReturnedName + "Returned");
} else {
boolean _containsKey = indexForMethod.containsKey(method.getName());
boolean _not = (!_containsKey);
if (_not) {
indexForMethod.put(method.getName(), Integer.valueOf(0));
}
final String methodSignature = this._methodUtil.createMethodSignatureFromOutParameters(method);
boolean _containsKey_1 = uniqueMultioutMethodSignatureToOutputContainerName.containsKey(methodSignature);
boolean _not_1 = (!_containsKey_1);
if (_not_1) {
Integer index = indexForMethod.get(method.getName());
index++;
indexForMethod.put(method.getName(), index);
String _firstUpper = StringExtensions.toFirstUpper(method.getName());
String _plus_5 = (_firstUpper + index);
uniqueMultioutMethodSignatureToOutputContainerName.put(methodSignature, _plus_5);
uniqueMultioutMethods.add(method);
}
final String outputContainerName = uniqueMultioutMethodSignatureToOutputContainerName.get(methodSignature);
String _callbackName_1 = callbackName;
callbackName = (_callbackName_1 + (outputContainerName + "Callback"));
String _futureName_1 = futureName;
futureName = (_futureName_1 + (outputContainerName + "Future"));
String _syncReturnedName_1 = syncReturnedName;
syncReturnedName = (_syncReturnedName_1 + (outputContainerName + "Returned"));
}
methodToCallbackName.put(method, callbackName);
methodToFutureName.put(method, futureName);
methodToSyncReturnedName.put(method, syncReturnedName);
}
}
}
@Override
public CharSequence generate(final boolean generateVersion) {
CharSequence _xblockexpression = null;
{
HashMap methodToCallbackName = new HashMap();
HashMap methodToFutureName = new HashMap();
HashMap methodToErrorEnumName = this._interfaceUtil.methodToErrorEnumName(this.francaIntf);
HashMap methodToSyncReturnedName = new HashMap();
ArrayList uniqueMultioutMethods = new ArrayList();
this.init(this.francaIntf, methodToCallbackName, methodToFutureName, methodToErrorEnumName, methodToSyncReturnedName, uniqueMultioutMethods, generateVersion);
final String interfaceName = this._namingUtil.joynrName(this.francaIntf);
final String asyncClassName = (interfaceName + "Async");
final String packagePath = this._joynrJavaGeneratorExtensions.getPackagePathWithJoynrPrefix(this.francaIntf, ".", generateVersion);
final boolean hasReadAttribute = this._interfaceUtil.hasReadAttribute(this.francaIntf);
final boolean hasWriteAttribute = this._interfaceUtil.hasWriteAttribute(this.francaIntf);
StringConcatenation _builder = new StringConcatenation();
CharSequence _warning = this._templateBase.warning();
_builder.append(_warning);
_builder.newLineIfNotEmpty();
_builder.append("package ");
_builder.append(packagePath);
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("import io.joynr.messaging.MessagingQos;");
_builder.newLine();
{
if (((this._interfaceUtil.getMethods(this.francaIntf).size() > 0) || hasReadAttribute)) {
_builder.append("import io.joynr.proxy.Callback;");
_builder.newLine();
{
boolean _hasMethodWithErrorEnum = this._interfaceUtil.hasMethodWithErrorEnum(this.francaIntf);
if (_hasMethodWithErrorEnum) {
_builder.append("import io.joynr.proxy.ICallbackWithModeledError;");
_builder.newLine();
_builder.append("import io.joynr.proxy.CallbackWithModeledError;");
_builder.newLine();
}
}
_builder.append("import io.joynr.proxy.Future;");
_builder.newLine();
_builder.append("import io.joynr.dispatcher.rpc.annotation.JoynrRpcCallback;");
_builder.newLine();
}
}
{
int _size = uniqueMultioutMethods.size();
boolean _greaterThan = (_size > 0);
if (_greaterThan) {
_builder.append("import io.joynr.proxy.ICallback;");
_builder.newLine();
}
}
_builder.append("import io.joynr.Async;");
_builder.newLine();
_builder.append("import io.joynr.ProvidedBy;");
_builder.newLine();
_builder.append("import io.joynr.UsedBy;");
_builder.newLine();
{
if (hasWriteAttribute) {
_builder.append("import io.joynr.exceptions.DiscoveryException;");
_builder.newLine();
}
}
_builder.newLine();
{
Iterable _requiredIncludesFor = this._joynrJavaGeneratorExtensions.getRequiredIncludesFor(this.francaIntf, true, true, true, false, false, false, generateVersion);
for(final String datatype : _requiredIncludesFor) {
_builder.append("import ");
_builder.append(datatype);
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
{
for(final FMethod method : uniqueMultioutMethods) {
final String syncReturnedName = methodToSyncReturnedName.get(method);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("import ");
_builder.append(packagePath, "\t");
_builder.append(".");
_builder.append(interfaceName, "\t");
_builder.append("Sync.");
_builder.append(syncReturnedName, "\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
_builder.append("@Async");
_builder.newLine();
_builder.append("@ProvidedBy(");
String _providerClassName = this._joynrJavaGeneratorExtensions.getProviderClassName(this.francaIntf);
_builder.append(_providerClassName);
_builder.append(".class)");
_builder.newLineIfNotEmpty();
_builder.append("@UsedBy(");
String _proxyClassName = this._joynrJavaGeneratorExtensions.getProxyClassName(this.francaIntf);
_builder.append(_proxyClassName);
_builder.append(".class)");
_builder.newLineIfNotEmpty();
_builder.append("public interface ");
_builder.append(asyncClassName);
_builder.append(" extends ");
_builder.append(interfaceName);
{
boolean _hasFireAndForgetMethods = this._interfaceUtil.hasFireAndForgetMethods(this.francaIntf);
if (_hasFireAndForgetMethods) {
_builder.append(", ");
_builder.append(interfaceName);
_builder.append("FireAndForget");
}
}
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
EList _attributes = this._interfaceUtil.getAttributes(this.francaIntf);
for(final FAttribute attribute : _attributes) {
_builder.append("\t");
String attributeName = this._namingUtil.joynrName(attribute);
_builder.newLineIfNotEmpty();
_builder.append("\t");
String attributeType = this._javaTypeUtil.getObjectDataTypeForPlainType(this._javaTypeUtil.getTypeName(attribute));
_builder.newLineIfNotEmpty();
_builder.append("\t");
String _firstUpper = StringExtensions.toFirstUpper(attributeName);
String getAttribute = ("get" + _firstUpper);
_builder.newLineIfNotEmpty();
_builder.append("\t");
String _firstUpper_1 = StringExtensions.toFirstUpper(attributeName);
String setAttribute = ("set" + _firstUpper_1);
_builder.newLineIfNotEmpty();
{
boolean _isReadable = this._attributeUtil.isReadable(attribute);
if (_isReadable) {
_builder.append("\t");
_builder.append("public Future<");
_builder.append(attributeType, "\t");
_builder.append("> ");
_builder.append(getAttribute, "\t");
_builder.append("(@JoynrRpcCallback(deserializationType = ");
_builder.append(attributeType, "\t");
{
boolean _isArray = this._javaTypeUtil.isArray(attribute);
if (_isArray) {
_builder.append("[]");
}
}
_builder.append(".class) Callback<");
_builder.append(attributeType, "\t");
_builder.append("> callback);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("default public Future<");
_builder.append(attributeType, "\t");
_builder.append("> ");
_builder.append(getAttribute, "\t");
_builder.append("(@JoynrRpcCallback(deserializationType = ");
_builder.append(attributeType, "\t");
{
boolean _isArray_1 = this._javaTypeUtil.isArray(attribute);
if (_isArray_1) {
_builder.append("[]");
}
}
_builder.append(".class) Callback<");
_builder.append(attributeType, "\t");
_builder.append("> callback, MessagingQos messagingQos) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return ");
_builder.append(getAttribute, "\t\t");
_builder.append("(callback);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
{
boolean _isWritable = this._attributeUtil.isWritable(attribute);
if (_isWritable) {
_builder.append("\t");
_builder.append("Future ");
_builder.append(setAttribute, "\t");
_builder.append("(@JoynrRpcCallback(deserializationType = Void.class) Callback callback, ");
_builder.append(attributeType, "\t");
_builder.append(" ");
_builder.append(attributeName, "\t");
_builder.append(") throws DiscoveryException;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("default Future ");
_builder.append(setAttribute, "\t");
_builder.append("(@JoynrRpcCallback(deserializationType = Void.class) Callback callback, ");
_builder.append(attributeType, "\t");
_builder.append(" ");
_builder.append(attributeName, "\t");
_builder.append(", MessagingQos messagingQos) throws DiscoveryException {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return ");
_builder.append(setAttribute, "\t\t");
_builder.append("(callback, ");
_builder.append(attributeName, "\t\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
}
}
_builder.newLine();
{
for(final FMethod method_1 : uniqueMultioutMethods) {
_builder.append("\t");
final String futureName = methodToFutureName.get(method_1);
_builder.newLineIfNotEmpty();
_builder.append("\t");
final String syncReturnedName_1 = methodToSyncReturnedName.get(method_1);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("public static class ");
_builder.append(futureName, "\t");
_builder.append(" extends Future<");
_builder.append(syncReturnedName_1, "\t");
_builder.append("> {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("public void resolve(Object... outParameters) {");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("if (outParameters.length == 0) {");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t\t");
_builder.append("onSuccess(null);");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("} else {");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t\t");
_builder.append("onSuccess(new ");
_builder.append(syncReturnedName_1, "\t\t\t\t");
_builder.append("(outParameters));");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
_builder.append("public static Class>[] getDatatypes() {");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("return ");
_builder.append(syncReturnedName_1, "\t\t\t");
_builder.append(".getDatatypes();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.newLine();
{
for(final FMethod method_2 : uniqueMultioutMethods) {
_builder.append("\t");
final String callbackName = methodToCallbackName.get(method_2);
_builder.newLineIfNotEmpty();
_builder.append("\t");
final int outputParametersLength = ((Object[])Conversions.unwrapArray(this._methodUtil.getOutputParameters(method_2), Object.class)).length;
_builder.newLineIfNotEmpty();
{
boolean _hasErrorEnum = this._methodUtil.hasErrorEnum(method_2);
if (_hasErrorEnum) {
{
FEnumerationType _errors = method_2.getErrors();
boolean _tripleNotEquals = (_errors != null);
if (_tripleNotEquals) {
_builder.append("\t");
String _get = methodToErrorEnumName.get(method_2);
final String errorEnumType = ((((packagePath + ".") + interfaceName) + ".") + _get);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("public abstract class ");
_builder.append(callbackName, "\t");
_builder.append(" implements ICallback, ICallbackWithModeledError<");
_builder.append(errorEnumType, "\t");
_builder.append("> {");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
String _buildPackagePath = this._joynrJavaGeneratorExtensions.buildPackagePath(method_2.getErrorEnum(), ".", true, generateVersion);
String _plus = (_buildPackagePath + ".");
String _joynrName = this._namingUtil.joynrName(method_2.getErrorEnum());
final String errorEnumType_1 = (_plus + _joynrName);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("public abstract class ");
_builder.append(callbackName, "\t");
_builder.append(" implements ICallback, ICallbackWithModeledError<");
_builder.append(errorEnumType_1, "\t");
_builder.append("> {");
_builder.newLineIfNotEmpty();
}
}
} else {
_builder.append("\t");
_builder.append("public abstract class ");
_builder.append(callbackName, "\t");
_builder.append(" implements ICallback {");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("\t");
_builder.append("public abstract void onSuccess(");
String _commaSeperatedTypedOutputParameterList = this._javaTypeUtil.getCommaSeperatedTypedOutputParameterList(method_2);
_builder.append(_commaSeperatedTypedOutputParameterList, "\t\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
_builder.append("public void resolve(Object... outParameters) {");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("if (outParameters.length < ");
_builder.append(outputParametersLength, "\t\t\t");
_builder.append(") {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t\t");
_builder.append("onSuccess(");
{
ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, outputParametersLength, true);
boolean _hasElements = false;
for(final Integer i : _doubleDotLessThan) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate(", ", "\t\t\t\t");
}
_builder.append("null");
}
}
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("} else {");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t\t\t");
int index = 0;
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t\t\t");
_builder.append("onSuccess(");
_builder.newLine();
{
Iterable _outputParameters = this._methodUtil.getOutputParameters(method_2);
for(final FArgument outParameter : _outputParameters) {
_builder.append("\t");
_builder.append("\t\t\t\t\t");
_builder.append("(");
String _typeName = this._javaTypeUtil.getTypeName(outParameter);
_builder.append(_typeName, "\t\t\t\t\t\t");
_builder.append(") outParameters[");
int _plusPlus = index++;
_builder.append(_plusPlus, "\t\t\t\t\t\t");
_builder.append("]");
{
int _length = ((Object[])Conversions.unwrapArray(this._methodUtil.getOutputParameters(method_2), Object.class)).length;
boolean _lessThan = (index < _length);
if (_lessThan) {
_builder.append(",");
}
}
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("\t\t\t");
_builder.append(");");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.newLine();
{
final Function1 _function = new Function1() {
@Override
public Boolean apply(final FMethod it) {
boolean _isFireAndForget = it.isFireAndForget();
return Boolean.valueOf((!_isFireAndForget));
}
};
Iterable _filter = IterableExtensions.filter(this._interfaceUtil.getMethods(this.francaIntf), _function);
for(final FMethod method_3 : _filter) {
_builder.append("\t");
String methodName = this._namingUtil.joynrName(method_3);
_builder.newLineIfNotEmpty();
_builder.append("\t");
String params = this._javaTypeUtil.getTypedParameterList(this._methodUtil.getInputParameters(method_3));
_builder.newLineIfNotEmpty();
_builder.append("\t");
String callbackParameter = this.getCallbackParameter(method_3, methodToCallbackName);
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("/*");
_builder.newLine();
_builder.append("\t");
_builder.append("* ");
_builder.append(methodName, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
String _get_1 = methodToFutureName.get(method_3);
_builder.append(_get_1, "\t");
_builder.append(" ");
_builder.append(methodName, "\t");
_builder.append("(");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append(callbackParameter, "\t\t\t");
{
boolean _isEmpty = IterableExtensions.isEmpty(this._methodUtil.getInputParameters(method_3));
boolean _not = (!_isEmpty);
if (_not) {
_builder.append(",");
}
}
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append(params, "\t\t\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(");");
_builder.newLine();
_builder.append("\t");
_builder.append("default public ");
String _get_2 = methodToFutureName.get(method_3);
_builder.append(_get_2, "\t");
_builder.append(" ");
_builder.append(methodName, "\t");
_builder.append("(");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append(callbackParameter, "\t\t\t");
{
boolean _isEmpty_1 = IterableExtensions.isEmpty(this._methodUtil.getInputParameters(method_3));
boolean _not_1 = (!_isEmpty_1);
if (_not_1) {
_builder.append(",");
}
}
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append(params, "\t\t\t");
_builder.append(",");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("MessagingQos messagingQos");
_builder.newLine();
_builder.append("\t");
_builder.append(") {");
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
_builder.append("return ");
_builder.append(methodName, "\t\t");
_builder.append("(");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("callback");
{
boolean _isEmpty_2 = IterableExtensions.isEmpty(this._methodUtil.getInputParameters(method_3));
boolean _not_2 = (!_isEmpty_2);
if (_not_2) {
_builder.append(",");
}
}
_builder.newLineIfNotEmpty();
{
Iterable _inputParameters = this._methodUtil.getInputParameters(method_3);
boolean _hasElements_1 = false;
for(final FArgument inParameter : _inputParameters) {
if (!_hasElements_1) {
_hasElements_1 = true;
} else {
_builder.appendImmediate(",", "\t\t\t");
}
_builder.append("\t");
_builder.append("\t\t");
String _name = inParameter.getName();
_builder.append(_name, "\t\t\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("\t");
_builder.append(");");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
}
}
_builder.append("}");
_builder.newLine();
_xblockexpression = _builder;
}
return _xblockexpression;
}
public String getCallbackParameter(final FMethod method, final HashMap methodToCallbackName) {
String outputParameterType = this._javaTypeUtil.getTypeNamesForOutputParameter(method).iterator().next();
String outputObjectType = this._javaTypeUtil.getObjectDataTypeForPlainType(outputParameterType);
String callbackType = methodToCallbackName.get(method);
int _size = IterableExtensions.size(this._methodUtil.getOutputParameters(method));
boolean _lessThan = (_size < 2);
if (_lessThan) {
boolean _notEquals = (!Objects.equal(outputParameterType, "void"));
if (_notEquals) {
boolean _equals = Objects.equal(outputObjectType, "");
if (_equals) {
throw new IllegalArgumentException((("error in method: " + method) + ". outputObjectType is empty even though outputParameterType is not void"));
} else {
return (((("@JoynrRpcCallback(deserializationType = " + outputObjectType) + ".class) ") + callbackType) + " callback");
}
} else {
return (("@JoynrRpcCallback(deserializationType = Void.class) " + callbackType) + " callback");
}
} else {
return (("@JoynrRpcCallback " + callbackType) + " callback");
}
}
}