use of com.robotoworks.mechanoid.net.netModel.BlockType in project mechanoid by robotoworks.
the class RequestGenerator method generateRequestClass.
public CharSequence generateRequestClass(final HttpMethod method, final Model module, final Client client) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("public class ");
String _name = method.getName();
String _pascalize = Strings.pascalize(_name);
_builder.append(_pascalize, "");
_builder.append("Request extends ");
{
boolean _hasBody = ModelExtensions.hasBody(method);
if (_hasBody) {
_builder.append("EntityEnclosed");
}
}
_builder.append("ServiceRequest {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("private static final String PATH = \"");
String _pathAsFormatString = ModelExtensions.getPathAsFormatString(method, this.serializer);
_builder.append(_pathAsFormatString, "\t");
_builder.append("\";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
{
Path _path = method.getPath();
EList<SimpleMemberAssignment> _params = null;
if (_path != null) {
_params = _path.getParams();
}
int _size = 0;
if (_params != null) {
_size = _params.size();
}
boolean _greaterThan = (_size > 0);
if (_greaterThan) {
{
Path _path_1 = method.getPath();
EList<SimpleMemberAssignment> _params_1 = _path_1.getParams();
for (final SimpleMemberAssignment slug : _params_1) {
_builder.append("\t");
_builder.append("private final ");
SimpleMember _member = slug.getMember();
IntrinsicType _type = _member.getType();
String _signature = ModelExtensions.signature(_type);
_builder.append(_signature, "\t");
_builder.append(" ");
SimpleMember _member_1 = slug.getMember();
String _name_1 = _member_1.getName();
String _camelize = Strings.camelize(_name_1);
_builder.append(_camelize, "\t");
_builder.append("Segment;");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.newLine();
}
}
_builder.append("\t");
ParamsBlock methodParams = ModelExtensions.getParamsBlock(method);
_builder.newLineIfNotEmpty();
_builder.append("\t");
ParamsBlock clientParams = ModelExtensions.getParamsBlock(client);
_builder.newLineIfNotEmpty();
{
boolean _notEquals = (!Objects.equal(methodParams, null));
if (_notEquals) {
{
EList<SimpleMemberAssignment> _params_2 = methodParams.getParams();
for (final SimpleMemberAssignment param : _params_2) {
_builder.append("\t");
_builder.append("private ");
SimpleMember _member_2 = param.getMember();
IntrinsicType _type_1 = _member_2.getType();
String _signature_1 = ModelExtensions.signature(_type_1);
_builder.append(_signature_1, "\t");
_builder.append(" ");
SimpleMember _member_3 = param.getMember();
String _name_2 = _member_3.getName();
String _camelize_1 = Strings.camelize(_name_2);
_builder.append(_camelize_1, "\t");
_builder.append("Param");
{
Literal _defaultValue = param.getDefaultValue();
boolean _notEquals_1 = (!Objects.equal(_defaultValue, null));
if (_notEquals_1) {
_builder.append(" = ");
Literal _defaultValue_1 = param.getDefaultValue();
String _convertToJavaLiteral = ModelExtensions.convertToJavaLiteral(_defaultValue_1);
_builder.append(_convertToJavaLiteral, "\t");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("private boolean ");
SimpleMember _member_4 = param.getMember();
String _name_3 = _member_4.getName();
String _camelize_2 = Strings.camelize(_name_3);
_builder.append(_camelize_2, "\t");
_builder.append("ParamSet");
{
Literal _defaultValue_2 = param.getDefaultValue();
boolean _notEquals_2 = (!Objects.equal(_defaultValue_2, null));
if (_notEquals_2) {
_builder.append(" = true");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("\t");
_builder.newLine();
}
}
{
boolean _notEquals_3 = (!Objects.equal(clientParams, null));
if (_notEquals_3) {
{
EList<SimpleMemberAssignment> _params_3 = clientParams.getParams();
for (final SimpleMemberAssignment param_1 : _params_3) {
_builder.append("\t");
_builder.append("private ");
SimpleMember _member_5 = param_1.getMember();
IntrinsicType _type_2 = _member_5.getType();
String _signature_2 = ModelExtensions.signature(_type_2);
_builder.append(_signature_2, "\t");
_builder.append(" ");
SimpleMember _member_6 = param_1.getMember();
String _name_4 = _member_6.getName();
String _camelize_3 = Strings.camelize(_name_4);
_builder.append(_camelize_3, "\t");
_builder.append("Param");
{
Literal _defaultValue_3 = param_1.getDefaultValue();
boolean _notEquals_4 = (!Objects.equal(_defaultValue_3, null));
if (_notEquals_4) {
_builder.append(" = ");
Literal _defaultValue_4 = param_1.getDefaultValue();
String _convertToJavaLiteral_1 = ModelExtensions.convertToJavaLiteral(_defaultValue_4);
_builder.append(_convertToJavaLiteral_1, "\t");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("private boolean ");
SimpleMember _member_7 = param_1.getMember();
String _name_5 = _member_7.getName();
String _camelize_4 = Strings.camelize(_name_5);
_builder.append(_camelize_4, "\t");
_builder.append("ParamSet");
{
Literal _defaultValue_5 = param_1.getDefaultValue();
boolean _notEquals_5 = (!Objects.equal(_defaultValue_5, null));
if (_notEquals_5) {
_builder.append(" = true");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("\t");
_builder.newLine();
}
}
{
boolean _hasBody_1 = ModelExtensions.hasBody(method);
if (_hasBody_1) {
_builder.append("\t");
BodyBlock _body = ModelExtensions.getBody(method);
BlockType _type_3 = _body.getType();
CharSequence _generateFieldForType = this.generateFieldForType(_type_3);
_builder.append(_generateFieldForType, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
BodyBlock _body_1 = ModelExtensions.getBody(method);
BlockType _type_4 = _body_1.getType();
CharSequence _generateGetterSetterForType = this.generateGetterSetterForType(_type_4);
_builder.append(_generateGetterSetterForType, "\t");
_builder.newLineIfNotEmpty();
}
}
{
boolean _notEquals_6 = (!Objects.equal(methodParams, null));
if (_notEquals_6) {
{
EList<SimpleMemberAssignment> _params_4 = methodParams.getParams();
for (final SimpleMemberAssignment param_2 : _params_4) {
_builder.append("\t");
_builder.append("public ");
String _name_6 = method.getName();
String _pascalize_1 = Strings.pascalize(_name_6);
_builder.append(_pascalize_1, "\t");
_builder.append("Request set");
SimpleMember _member_8 = param_2.getMember();
String _name_7 = _member_8.getName();
String _pascalize_2 = Strings.pascalize(_name_7);
_builder.append(_pascalize_2, "\t");
_builder.append("Param(");
SimpleMember _member_9 = param_2.getMember();
IntrinsicType _type_5 = _member_9.getType();
String _signature_3 = ModelExtensions.signature(_type_5);
_builder.append(_signature_3, "\t");
_builder.append(" value) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("this.");
SimpleMember _member_10 = param_2.getMember();
String _name_8 = _member_10.getName();
String _camelize_5 = Strings.camelize(_name_8);
_builder.append(_camelize_5, "\t\t");
_builder.append("Param = value;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("this.");
SimpleMember _member_11 = param_2.getMember();
String _name_9 = _member_11.getName();
String _camelize_6 = Strings.camelize(_name_9);
_builder.append(_camelize_6, "\t\t");
_builder.append("ParamSet = true;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return this;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public boolean is");
SimpleMember _member_12 = param_2.getMember();
String _name_10 = _member_12.getName();
String _pascalize_3 = Strings.pascalize(_name_10);
_builder.append(_pascalize_3, "\t");
_builder.append("ParamSet() {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return ");
SimpleMember _member_13 = param_2.getMember();
String _name_11 = _member_13.getName();
String _camelize_7 = Strings.camelize(_name_11);
_builder.append(_camelize_7, "\t\t");
_builder.append("ParamSet;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.append("\t");
_builder.append("\t");
_builder.newLine();
}
}
{
boolean _notEquals_7 = (!Objects.equal(clientParams, null));
if (_notEquals_7) {
{
EList<SimpleMemberAssignment> _params_5 = clientParams.getParams();
for (final SimpleMemberAssignment param_3 : _params_5) {
_builder.append("\t");
_builder.append("public ");
String _name_12 = method.getName();
String _pascalize_4 = Strings.pascalize(_name_12);
_builder.append(_pascalize_4, "\t");
_builder.append("Request set");
SimpleMember _member_14 = param_3.getMember();
String _name_13 = _member_14.getName();
String _pascalize_5 = Strings.pascalize(_name_13);
_builder.append(_pascalize_5, "\t");
_builder.append("Param(");
SimpleMember _member_15 = param_3.getMember();
IntrinsicType _type_6 = _member_15.getType();
String _signature_4 = ModelExtensions.signature(_type_6);
_builder.append(_signature_4, "\t");
_builder.append(" value) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("this.");
SimpleMember _member_16 = param_3.getMember();
String _name_14 = _member_16.getName();
String _camelize_8 = Strings.camelize(_name_14);
_builder.append(_camelize_8, "\t\t");
_builder.append("Param = value;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("this.");
SimpleMember _member_17 = param_3.getMember();
String _name_15 = _member_17.getName();
String _camelize_9 = Strings.camelize(_name_15);
_builder.append(_camelize_9, "\t\t");
_builder.append("ParamSet = true;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return this;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public boolean is");
SimpleMember _member_18 = param_3.getMember();
String _name_16 = _member_18.getName();
String _pascalize_6 = Strings.pascalize(_name_16);
_builder.append(_pascalize_6, "\t");
_builder.append("ParamSet() {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return ");
SimpleMember _member_19 = param_3.getMember();
String _name_17 = _member_19.getName();
String _camelize_10 = Strings.camelize(_name_17);
_builder.append(_camelize_10, "\t\t");
_builder.append("ParamSet;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.append("\t");
_builder.append("\t\t");
_builder.newLine();
}
}
_builder.append("\t");
_builder.append("public ");
String _name_18 = method.getName();
String _pascalize_7 = Strings.pascalize(_name_18);
_builder.append(_pascalize_7, "\t");
_builder.append("Request(");
Path _path_2 = method.getPath();
BodyBlock _body_2 = ModelExtensions.getBody(method);
String _generateRequestConstructorArgs = this.generateRequestConstructorArgs(_path_2, _body_2);
_builder.append(_generateRequestConstructorArgs, "\t");
_builder.append("){");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
HeaderBlock methodHeaders = ModelExtensions.getHeaderBlock(method);
_builder.newLineIfNotEmpty();
{
boolean _notEquals_8 = (!Objects.equal(methodHeaders, null));
if (_notEquals_8) {
{
EList<Header> _headers = methodHeaders.getHeaders();
for (final Header header : _headers) {
_builder.append("\t\t");
_builder.append("setHeader(\"");
String _name_19 = header.getName();
_builder.append(_name_19, "\t\t");
_builder.append("\",\"");
String _value = header.getValue();
_builder.append(_value, "\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t\t");
_builder.newLine();
}
}
{
Path _path_3 = method.getPath();
EList<SimpleMemberAssignment> _params_6 = null;
if (_path_3 != null) {
_params_6 = _path_3.getParams();
}
int _size_1 = 0;
if (_params_6 != null) {
_size_1 = _params_6.size();
}
boolean _greaterThan_1 = (_size_1 > 0);
if (_greaterThan_1) {
{
Path _path_4 = method.getPath();
EList<SimpleMemberAssignment> _params_7 = _path_4.getParams();
for (final SimpleMemberAssignment slug_1 : _params_7) {
_builder.append("\t\t");
_builder.append("this.");
SimpleMember _member_20 = slug_1.getMember();
String _name_20 = _member_20.getName();
String _camelize_11 = Strings.camelize(_name_20);
_builder.append(_camelize_11, "\t\t");
_builder.append("Segment = ");
SimpleMember _member_21 = slug_1.getMember();
String _name_21 = _member_21.getName();
String _camelize_12 = Strings.camelize(_name_21);
_builder.append(_camelize_12, "\t\t");
_builder.append("Segment;");
_builder.newLineIfNotEmpty();
}
}
}
}
{
boolean _hasBody_2 = ModelExtensions.hasBody(method);
if (_hasBody_2) {
_builder.append("\t\t");
BodyBlock _body_3 = ModelExtensions.getBody(method);
BlockType _type_7 = _body_3.getType();
CharSequence _generateConstructorAssignmentForType = this.generateConstructorAssignmentForType(_type_7);
_builder.append(_generateConstructorAssignmentForType, "\t\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
{
boolean _hasBody_3 = ModelExtensions.hasBody(method);
if (_hasBody_3) {
_builder.append("\t");
this.imports.addImport("com.robotoworks.mechanoid.util.Closeables");
_builder.newLineIfNotEmpty();
_builder.append("\t");
this.imports.addImport("java.io.OutputStream");
_builder.newLineIfNotEmpty();
_builder.append("\t");
this.imports.addImport("java.io.IOException");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public void writeBody(JsonEntityWriterProvider provider, OutputStream stream) throws IOException {");
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
BodyBlock _body_4 = ModelExtensions.getBody(method);
BodyBlock _body_5 = ModelExtensions.getBody(method);
BlockType _type_8 = _body_5.getType();
CharSequence _generateSerializationStatementForType = this.generateSerializationStatementForType(method, _body_4, _type_8);
_builder.append(_generateSerializationStatementForType, "\t\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
}
}
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public String createUrl(String baseUrl){");
_builder.newLine();
{
Path _path_5 = method.getPath();
EList<SimpleMemberAssignment> _params_8 = null;
if (_path_5 != null) {
_params_8 = _path_5.getParams();
}
int _size_2 = 0;
if (_params_8 != null) {
_size_2 = _params_8.size();
}
boolean _greaterThan_2 = (_size_2 > 0);
if (_greaterThan_2) {
_builder.append("\t\t");
_builder.append("Uri.Builder uriBuilder = Uri.parse(baseUrl + String.format(PATH, ");
{
Path _path_6 = method.getPath();
EList<SimpleMemberAssignment> _params_9 = _path_6.getParams();
boolean _hasElements = false;
for (final SimpleMemberAssignment slug_2 : _params_9) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate(", ", "\t\t");
}
SimpleMember _member_22 = slug_2.getMember();
String _name_22 = _member_22.getName();
String _camelize_13 = Strings.camelize(_name_22);
_builder.append(_camelize_13, "\t\t");
_builder.append("Segment");
}
}
_builder.append(")).buildUpon();");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t\t");
_builder.append("Uri.Builder uriBuilder = Uri.parse(baseUrl + PATH).buildUpon();");
_builder.newLine();
}
}
_builder.append("\t\t\t");
_builder.newLine();
{
boolean _notEquals_9 = (!Objects.equal(methodParams, null));
if (_notEquals_9) {
{
EList<SimpleMemberAssignment> _params_10 = methodParams.getParams();
for (final SimpleMemberAssignment param_4 : _params_10) {
_builder.append("\t\t");
_builder.append("if(");
SimpleMember _member_23 = param_4.getMember();
String _name_23 = _member_23.getName();
String _camelize_14 = Strings.camelize(_name_23);
_builder.append(_camelize_14, "\t\t");
_builder.append("ParamSet){");
_builder.newLineIfNotEmpty();
{
SimpleMember _member_24 = param_4.getMember();
IntrinsicType _type_9 = _member_24.getType();
if ((_type_9 instanceof StringType)) {
_builder.append("\t\t");
_builder.append("\t");
_builder.append("uriBuilder.appendQueryParameter(\"");
SimpleMember _member_25 = param_4.getMember();
String _name_24 = _member_25.getName();
_builder.append(_name_24, "\t\t\t");
_builder.append("\", ");
SimpleMember _member_26 = param_4.getMember();
String _name_25 = _member_26.getName();
String _camelize_15 = Strings.camelize(_name_25);
_builder.append(_camelize_15, "\t\t\t");
_builder.append("Param);");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t\t");
_builder.append("\t");
_builder.append("uriBuilder.appendQueryParameter(\"");
SimpleMember _member_27 = param_4.getMember();
String _name_26 = _member_27.getName();
_builder.append(_name_26, "\t\t\t");
_builder.append("\", String.valueOf(");
SimpleMember _member_28 = param_4.getMember();
String _name_27 = _member_28.getName();
String _camelize_16 = Strings.camelize(_name_27);
_builder.append(_camelize_16, "\t\t\t");
_builder.append("Param));");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.append("\t\t");
_builder.newLine();
}
}
{
boolean _notEquals_10 = (!Objects.equal(clientParams, null));
if (_notEquals_10) {
{
EList<SimpleMemberAssignment> _params_11 = clientParams.getParams();
for (final SimpleMemberAssignment param_5 : _params_11) {
_builder.append("\t\t");
_builder.append("if(");
SimpleMember _member_29 = param_5.getMember();
String _name_28 = _member_29.getName();
String _camelize_17 = Strings.camelize(_name_28);
_builder.append(_camelize_17, "\t\t");
_builder.append("ParamSet){");
_builder.newLineIfNotEmpty();
{
SimpleMember _member_30 = param_5.getMember();
IntrinsicType _type_10 = _member_30.getType();
if ((_type_10 instanceof StringType)) {
_builder.append("\t\t");
_builder.append("\t");
_builder.append("uriBuilder.appendQueryParameter(\"");
SimpleMember _member_31 = param_5.getMember();
String _name_29 = _member_31.getName();
_builder.append(_name_29, "\t\t\t");
_builder.append("\", ");
SimpleMember _member_32 = param_5.getMember();
String _name_30 = _member_32.getName();
String _camelize_18 = Strings.camelize(_name_30);
_builder.append(_camelize_18, "\t\t\t");
_builder.append("Param);");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t\t");
_builder.append("\t");
_builder.append("uriBuilder.appendQueryParameter(\"");
SimpleMember _member_33 = param_5.getMember();
String _name_31 = _member_33.getName();
_builder.append(_name_31, "\t\t\t");
_builder.append("\", String.valueOf(");
SimpleMember _member_34 = param_5.getMember();
String _name_32 = _member_34.getName();
String _camelize_19 = Strings.camelize(_name_32);
_builder.append(_camelize_19, "\t\t\t");
_builder.append("Param));");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.append("\t\t");
_builder.newLine();
}
}
_builder.append("\t\t");
_builder.append("return uriBuilder.toString();\t\t\t");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder;
}
use of com.robotoworks.mechanoid.net.netModel.BlockType in project mechanoid by robotoworks.
the class RequestGenerator method generateRequestConstructorArgs.
/**
* Converts a path (eg:- /qux/:fooparam/:quxparam/bar
* into constructor arguments
*/
public String generateRequestConstructorArgs(final Path path, final BodyBlock body) {
ArrayList<String> args = new ArrayList<String>();
EList<SimpleMemberAssignment> _params = null;
if (path != null) {
_params = path.getParams();
}
int _size = 0;
if (_params != null) {
_size = _params.size();
}
boolean _greaterThan = (_size > 0);
if (_greaterThan) {
EList<SimpleMemberAssignment> _params_1 = path.getParams();
for (final SimpleMemberAssignment slug : _params_1) {
SimpleMember _member = slug.getMember();
IntrinsicType _type = _member.getType();
String _signature = ModelExtensions.signature(_type);
String _plus = (_signature + " ");
SimpleMember _member_1 = slug.getMember();
String _name = _member_1.getName();
String _camelize = Strings.camelize(_name);
String _plus_1 = (_plus + _camelize);
String _plus_2 = (_plus_1 + "Segment");
args.add(_plus_2);
}
}
boolean _notEquals = (!Objects.equal(body, null));
if (_notEquals) {
BlockType _type_1 = body.getType();
this.buildConstructorArgsForType(_type_1, args);
}
return IterableExtensions.join(args, ",\n");
}
use of com.robotoworks.mechanoid.net.netModel.BlockType in project mechanoid by robotoworks.
the class ResultGenerator method generateResponseClass.
public CharSequence generateResponseClass(final HttpMethod method, final Model module, final Client client) {
StringConcatenation _builder = new StringConcatenation();
final ResponseBlock responseBlock = ModelExtensions.getResponseBlock(method);
_builder.newLineIfNotEmpty();
_builder.append("public class ");
String _name = method.getName();
String _pascalize = Strings.pascalize(_name);
_builder.append(_pascalize, "");
_builder.append("Result extends ServiceResult {");
_builder.newLineIfNotEmpty();
{
BlockType _type = null;
if (responseBlock != null) {
_type = responseBlock.getType();
}
boolean _notEquals = (!Objects.equal(_type, null));
if (_notEquals) {
_builder.append("\t");
BlockType _type_1 = responseBlock.getType();
CharSequence _generateFieldForType = this.generateFieldForType(_type_1);
_builder.append(_generateFieldForType, "\t");
_builder.append("\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
BlockType _type_2 = responseBlock.getType();
CharSequence _generateGetterForType = this.generateGetterForType(_type_2);
_builder.append(_generateGetterForType, "\t");
_builder.append("\t");
_builder.newLineIfNotEmpty();
}
}
{
ComplexTypeDeclaration _superType = null;
if (responseBlock != null) {
_superType = responseBlock.getSuperType();
}
boolean _notEquals_1 = (!Objects.equal(_superType, null));
if (_notEquals_1) {
_builder.append("\t");
_builder.append("private ");
ComplexTypeDeclaration _superType_1 = responseBlock.getSuperType();
String _name_1 = _superType_1.getName();
String _pascalize_1 = Strings.pascalize(_name_1);
_builder.append(_pascalize_1, "\t");
_builder.append(" base;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
ComplexTypeDeclaration _superType_2 = responseBlock.getSuperType();
ComplexTypeLiteral _literal = _superType_2.getLiteral();
EList<Member> _members = _literal.getMembers();
final Function1<Member, Boolean> _function = new Function1<Member, Boolean>() {
public Boolean apply(final Member superMember) {
BlockType _type = null;
if (responseBlock != null) {
_type = responseBlock.getType();
}
if ((_type instanceof ComplexTypeLiteral)) {
BlockType _type_1 = responseBlock.getType();
EList<Member> _members = ((ComplexTypeLiteral) _type_1).getMembers();
final Function1<Member, Boolean> _function = new Function1<Member, Boolean>() {
public Boolean apply(final Member member) {
String _name = superMember.getName();
String _name_1 = member.getName();
return Boolean.valueOf(_name.equals(_name_1));
}
};
Member _findFirst = IterableExtensions.<Member>findFirst(_members, _function);
return Boolean.valueOf(Objects.equal(_findFirst, null));
}
return Boolean.valueOf(true);
}
};
Iterable<Member> _filter = IterableExtensions.<Member>filter(_members, _function);
CharSequence _generateBaseAccessors = this.generateBaseAccessors(_filter);
_builder.append(_generateBaseAccessors, "\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
String _name_2 = method.getName();
String _pascalize_2 = Strings.pascalize(_name_2);
_builder.append(_pascalize_2, "\t");
_builder.append("Result(JsonEntityReaderProvider provider, InputStream inStream) throws IOException {");
_builder.newLineIfNotEmpty();
{
boolean _notEquals_2 = (!Objects.equal(responseBlock, null));
if (_notEquals_2) {
{
boolean _or = false;
BlockType _type_3 = responseBlock.getType();
if ((_type_3 instanceof ComplexTypeLiteral)) {
_or = true;
} else {
ComplexTypeDeclaration _superType_3 = responseBlock.getSuperType();
boolean _notEquals_3 = (!Objects.equal(_superType_3, null));
_or = _notEquals_3;
}
if (_or) {
_builder.append("\t");
CharSequence _generateDeserializationStatementHeader = this.generateDeserializationStatementHeader(true);
_builder.append(_generateDeserializationStatementHeader, "\t");
_builder.newLineIfNotEmpty();
{
ComplexTypeDeclaration _superType_4 = responseBlock.getSuperType();
boolean _notEquals_4 = (!Objects.equal(_superType_4, null));
if (_notEquals_4) {
_builder.append("\t");
_builder.append("\t");
_builder.append("this.base = new ");
ComplexTypeDeclaration _superType_5 = responseBlock.getSuperType();
String _name_3 = _superType_5.getName();
String _pascalize_3 = Strings.pascalize(_name_3);
_builder.append(_pascalize_3, "\t\t");
_builder.append("();");
_builder.newLineIfNotEmpty();
}
}
{
BlockType _type_4 = responseBlock.getType();
if ((_type_4 instanceof ComplexTypeLiteral)) {
_builder.append("\t");
_builder.append("\t");
String _name_4 = method.getName();
String _pascalize_4 = Strings.pascalize(_name_4);
_builder.append(_pascalize_4, "\t\t");
_builder.append("Result subject = this;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
BlockType _type_5 = responseBlock.getType();
ComplexTypeDeclaration _superType_6 = null;
if (responseBlock != null) {
_superType_6 = responseBlock.getSuperType();
}
ComplexTypeLiteral _literal_1 = null;
if (_superType_6 != null) {
_literal_1 = _superType_6.getLiteral();
}
EList<Member> _mergeMembers = this.mergeMembers(((ComplexTypeLiteral) _type_5), _literal_1);
CharSequence _genReadComplexTypeLiteralForMembers = this.jsonReaderGenerator.genReadComplexTypeLiteralForMembers(_mergeMembers);
_builder.append(_genReadComplexTypeLiteralForMembers, "\t\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
CharSequence _generateDeserializationStatementFooter = this.generateDeserializationStatementFooter(true);
_builder.append(_generateDeserializationStatementFooter, "\t");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
BlockType _type_6 = responseBlock.getType();
CharSequence _generateDeserializationStatementForType = this.generateDeserializationStatementForType(responseBlock, ((Type) _type_6));
_builder.append(_generateDeserializationStatementForType, "\t");
_builder.newLineIfNotEmpty();
}
}
} else {
_builder.append("\t");
_builder.append("Closeables.closeSilently(inStream);");
_builder.newLine();
}
}
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder;
}
use of com.robotoworks.mechanoid.net.netModel.BlockType in project mechanoid by robotoworks.
the class BodyBlockImpl method basicSetType.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetType(BlockType newType, NotificationChain msgs) {
BlockType oldType = type;
type = newType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, NetModelPackage.BODY_BLOCK__TYPE, oldType, newType);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of com.robotoworks.mechanoid.net.netModel.BlockType in project mechanoid by robotoworks.
the class ResponseBlockImpl method basicSetType.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetType(BlockType newType, NotificationChain msgs) {
BlockType oldType = type;
type = newType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, NetModelPackage.RESPONSE_BLOCK__TYPE, oldType, newType);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
Aggregations