All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
io.joynr.generator.interfaces.InterfaceStatelessAsyncCallbackTemplate 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.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.HashMap;
import java.util.HashSet;
import org.eclipse.emf.common.util.EList;
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.eclipse.xtext.xbase.lib.StringExtensions;
import org.franca.core.franca.FAttribute;
import org.franca.core.franca.FEnumerationType;
import org.franca.core.franca.FMethod;
@SuppressWarnings("all")
public class InterfaceStatelessAsyncCallbackTemplate 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;
@Inject
@Extension
private AttributeUtil _attributeUtil;
@Override
public CharSequence generate(final boolean generateVersion) {
CharSequence _xblockexpression = null;
{
final String interfaceName = this._namingUtil.joynrName(this.francaIntf);
final String statelessAsyncClassName = (interfaceName + "StatelessAsyncCallback");
final String packagePath = this._joynrJavaGeneratorExtensions.getPackagePathWithJoynrPrefix(this.francaIntf, ".", generateVersion);
HashMap methodToErrorEnumName = this._interfaceUtil.methodToErrorEnumName(this.francaIntf);
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.exceptions.JoynrRuntimeException;");
_builder.newLine();
_builder.append("import io.joynr.proxy.ReplyContext;");
_builder.newLine();
_builder.append("import io.joynr.proxy.StatelessAsyncCallback;");
_builder.newLine();
_builder.append("import io.joynr.dispatcher.rpc.annotation.StatelessCallbackCorrelation;");
_builder.newLine();
_builder.append("import io.joynr.UsedBy;");
_builder.newLine();
_builder.newLine();
{
Iterable _requiredStatelessAsyncCallbackIncludesFor = this._joynrJavaGeneratorExtensions.getRequiredStatelessAsyncCallbackIncludesFor(this.francaIntf, generateVersion);
for(final String datatype : _requiredStatelessAsyncCallbackIncludesFor) {
_builder.append("import ");
_builder.append(datatype);
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
_builder.append("@UsedBy(");
String _proxyClassName = this._joynrJavaGeneratorExtensions.getProxyClassName(this.francaIntf);
_builder.append(_proxyClassName);
_builder.append(".class)");
_builder.newLineIfNotEmpty();
_builder.append("public interface ");
_builder.append(statelessAsyncClassName);
_builder.append(" extends StatelessAsyncCallback {");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
EList _attributes = this._interfaceUtil.getAttributes(this.francaIntf);
boolean _hasElements = false;
for(final FAttribute attribute : _attributes) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate("\n", "");
}
String attributeName = this._namingUtil.joynrName(attribute);
_builder.newLineIfNotEmpty();
String attributeType = this._javaTypeUtil.getObjectDataTypeForPlainType(this._javaTypeUtil.getTypeName(attribute));
_builder.newLineIfNotEmpty();
String _firstUpper = StringExtensions.toFirstUpper(attributeName);
String getAttribute = ("get" + _firstUpper);
_builder.newLineIfNotEmpty();
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("/*");
_builder.newLine();
_builder.append("\t");
_builder.append("* ");
_builder.append(attributeName, "\t");
_builder.append(" getter");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("@StatelessCallbackCorrelation(\"");
int _hashCode = getAttribute.hashCode();
_builder.append(_hashCode, "\t");
_builder.append("\")");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("default void ");
_builder.append(getAttribute, "\t");
_builder.append("Success(");
_builder.append(attributeType, "\t");
_builder.append(" ");
_builder.append(attributeName, "\t");
_builder.append(", ReplyContext replyContext)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("{ throw new UnsupportedOperationException(\"");
_builder.append(getAttribute, "\t");
_builder.append("Success not implemented for callback instance\"); }");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("@StatelessCallbackCorrelation(\"");
int _hashCode_1 = getAttribute.hashCode();
_builder.append(_hashCode_1, "\t");
_builder.append("\")");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("default void ");
_builder.append(getAttribute, "\t");
_builder.append("Failed(");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("JoynrRuntimeException runtimeException,");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("ReplyContext replyContext");
_builder.newLine();
_builder.append("\t");
_builder.append(") { throw new UnsupportedOperationException(\"");
_builder.append(getAttribute, "\t");
_builder.append("Failed not implemented for callback instance\"); }");
_builder.newLineIfNotEmpty();
}
}
{
boolean _isWritable = this._attributeUtil.isWritable(attribute);
if (_isWritable) {
_builder.append("\t");
_builder.append("/*");
_builder.newLine();
_builder.append("\t");
_builder.append("* ");
_builder.append(attributeName, "\t");
_builder.append(" setter");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("@StatelessCallbackCorrelation(\"");
int _hashCode_2 = setAttribute.hashCode();
_builder.append(_hashCode_2, "\t");
_builder.append("\")");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("default void ");
_builder.append(setAttribute, "\t");
_builder.append("Success(ReplyContext replyContext)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("{ throw new UnsupportedOperationException(\"");
_builder.append(setAttribute, "\t");
_builder.append("Success not implemented for callback instance\"); }");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("@StatelessCallbackCorrelation(\"");
int _hashCode_3 = setAttribute.hashCode();
_builder.append(_hashCode_3, "\t");
_builder.append("\")");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("default void ");
_builder.append(setAttribute, "\t");
_builder.append("Failed(");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("JoynrRuntimeException runtimeException,");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("ReplyContext replyContext");
_builder.newLine();
_builder.append("\t");
_builder.append(") { throw new UnsupportedOperationException(\"");
_builder.append(setAttribute, "\t");
_builder.append("Failed not implemented for callback instance\"); }");
_builder.newLineIfNotEmpty();
}
}
}
}
_builder.newLine();
HashSet successMethodsGenerated = new HashSet();
_builder.newLineIfNotEmpty();
HashSet failedWithExceptionMethodsGenerated = new HashSet();
_builder.newLineIfNotEmpty();
HashSet failedWithErrorMethodsGenerated = new HashSet();
_builder.newLineIfNotEmpty();
{
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);
boolean _hasElements_1 = false;
for(final FMethod method : _filter) {
if (!_hasElements_1) {
_hasElements_1 = true;
} else {
_builder.appendImmediate("\n", "");
}
String methodSignature = this._methodUtil.createMethodSignatureFromOutParameters(method);
_builder.newLineIfNotEmpty();
String methodName = this._namingUtil.joynrName(method);
_builder.newLineIfNotEmpty();
{
boolean _add = successMethodsGenerated.add(methodSignature);
if (_add) {
_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("@StatelessCallbackCorrelation(\"");
int _hashCode_4 = methodSignature.hashCode();
_builder.append(_hashCode_4, "\t");
_builder.append("\")");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("default void ");
_builder.append(methodName, "\t");
_builder.append("Success(");
_builder.newLineIfNotEmpty();
{
int _size = IterableExtensions.size(this._methodUtil.getOutputParameters(method));
boolean _greaterThan = (_size > 0);
if (_greaterThan) {
_builder.append("\t");
_builder.append("\t\t");
String _typedParameterList = this._javaTypeUtil.getTypedParameterList(this._methodUtil.getOutputParameters(method));
_builder.append(_typedParameterList, "\t\t\t");
_builder.append(",");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("\t\t");
_builder.append("ReplyContext replyContext");
_builder.newLine();
_builder.append("\t");
_builder.append(") { throw new UnsupportedOperationException(\"");
_builder.append(methodName, "\t");
_builder.append("Success not implemented for callback instance\"); }");
_builder.newLineIfNotEmpty();
}
}
{
if ((this._methodUtil.hasErrorEnum(method) && failedWithErrorMethodsGenerated.add(this._methodUtil.createMethodSignatureFromErrors(method)))) {
_builder.append("\t");
_builder.append("default void ");
_builder.append(methodName, "\t");
_builder.append("Failed(");
_builder.newLineIfNotEmpty();
{
FEnumerationType _errors = method.getErrors();
boolean _tripleNotEquals = (_errors != null);
if (_tripleNotEquals) {
_builder.append("\t");
_builder.append("\t");
String _get = methodToErrorEnumName.get(method);
final String errorEnumType = ((((packagePath + ".") + interfaceName) + ".") + _get);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
_builder.append(errorEnumType, "\t\t\t");
_builder.append(" error,");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
_builder.append("\t");
String _buildPackagePath = this._joynrJavaGeneratorExtensions.buildPackagePath(method.getErrorEnum(), ".", true, generateVersion);
String _plus = (_buildPackagePath + ".");
String _joynrName = this._namingUtil.joynrName(method.getErrorEnum());
final String errorEnumType_1 = (_plus + _joynrName);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
_builder.append(errorEnumType_1, "\t\t\t");
_builder.append(" error,");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("\t\t");
_builder.append("ReplyContext replyContext");
_builder.newLine();
_builder.append("\t");
_builder.append(") { throw new UnsupportedOperationException(\"");
_builder.append(methodName, "\t");
_builder.append("Failed with error not implemented for callback instance\"); }");
_builder.newLineIfNotEmpty();
}
}
{
boolean _add_1 = failedWithExceptionMethodsGenerated.add(methodName);
if (_add_1) {
_builder.append("\t");
_builder.append("default void ");
_builder.append(methodName, "\t");
_builder.append("Failed(");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("JoynrRuntimeException runtimeException,");
_builder.newLine();
_builder.append("\t");
_builder.append("\t\t");
_builder.append("ReplyContext replyContext");
_builder.newLine();
_builder.append("\t");
_builder.append(") { throw new UnsupportedOperationException(\"");
_builder.append(methodName, "\t");
_builder.append("Failed with exception not implemented for callback instance\"); }");
_builder.newLineIfNotEmpty();
}
}
}
}
_builder.append("}");
_builder.newLine();
_xblockexpression = _builder;
}
return _xblockexpression;
}
}