io.joynr.generator.interfaces.InterfaceFireAndForgetTemplate Maven / Gradle / Ivy
package io.joynr.generator.interfaces;
import com.google.inject.Inject;
import io.joynr.generator.templates.InterfaceTemplate;
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 org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.franca.core.franca.FMethod;
@SuppressWarnings("all")
public class InterfaceFireAndForgetTemplate extends InterfaceTemplate {
@Inject
@Extension
private JoynrJavaGeneratorExtensions _joynrJavaGeneratorExtensions;
@Inject
@Extension
private JavaTypeUtil _javaTypeUtil;
@Inject
@Extension
private MethodUtil _methodUtil;
@Inject
@Extension
private InterfaceUtil _interfaceUtil;
@Inject
@Extension
private NamingUtil _namingUtil;
@Inject
@Extension
private TemplateBase _templateBase;
@Override
public CharSequence generate(final boolean generateVersion) {
CharSequence _xblockexpression = null;
{
final String packagePath = this._joynrJavaGeneratorExtensions.getPackagePathWithJoynrPrefix(this.francaIntf, ".", generateVersion);
StringConcatenation _builder = new StringConcatenation();
CharSequence _warning = this._templateBase.warning();
_builder.append(_warning);
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("package ");
_builder.append(packagePath);
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("import io.joynr.messaging.MessagingQos;");
_builder.newLine();
_builder.newLine();
{
Iterable _requiredIncludesFor = this._joynrJavaGeneratorExtensions.getRequiredIncludesFor(this.francaIntf, false, false, false, false, false, true, generateVersion);
for(final String datatype : _requiredIncludesFor) {
_builder.append("import ");
_builder.append(datatype);
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
_builder.append("@io.joynr.dispatcher.rpc.annotation.FireAndForget");
_builder.newLine();
_builder.append("public interface ");
String _joynrName = this._namingUtil.joynrName(this.francaIntf);
String _plus = (_joynrName + "FireAndForget");
_builder.append(_plus);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
final Function1 _function = new Function1() {
@Override
public Boolean apply(final FMethod it) {
return Boolean.valueOf(it.isFireAndForget());
}
};
Iterable _filter = IterableExtensions.filter(this._interfaceUtil.getMethods(this.francaIntf), _function);
boolean _hasElements = false;
for(final FMethod method : _filter) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate("\n", "");
}
String methodName = this._namingUtil.joynrName(method);
_builder.newLineIfNotEmpty();
_builder.append("/*");
_builder.newLine();
_builder.append(" ");
_builder.append("* ");
_builder.append(methodName, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("void ");
_builder.append(methodName);
_builder.append("(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
String _typedParameterList = this._javaTypeUtil.getTypedParameterList(this._methodUtil.getInputParameters(method));
_builder.append(_typedParameterList, "\t\t");
_builder.newLineIfNotEmpty();
_builder.append(");");
_builder.newLine();
_builder.append("default void ");
_builder.append(methodName);
_builder.append("(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
String _typedParameterList_1 = this._javaTypeUtil.getTypedParameterList(this._methodUtil.getInputParameters(method));
_builder.append(_typedParameterList_1, "\t\t");
{
boolean _isEmpty = IterableExtensions.isEmpty(this._methodUtil.getInputParameters(method));
boolean _not = (!_isEmpty);
if (_not) {
_builder.append(",");
}
}
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("MessagingQos messagingQos");
_builder.newLine();
_builder.append(") {");
_builder.newLine();
_builder.append("};");
_builder.newLine();
}
}
_builder.append("}");
_builder.newLine();
_xblockexpression = _builder;
}
return _xblockexpression;
}
}