use of com.robotoworks.mechanoid.net.generator.ImportHelper in project mechanoid by robotoworks.
the class JsonReaderStatementGenerator method _genStatement.
protected CharSequence _genStatement(final SkipMember skipMember) {
StringConcatenation _builder = new StringConcatenation();
ImportHelper _imports = this.getImports();
_imports.addImport("com.robotoworks.mechanoid.internal.util.JsonToken");
_builder.newLineIfNotEmpty();
String _readerIdentifier = this.getReaderIdentifier();
_builder.append(_readerIdentifier, "");
_builder.append(".beginObject();");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("while(");
String _readerIdentifier_1 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_1, "");
_builder.append(".hasNext()) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("name = ");
String _readerIdentifier_2 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_2, "\t");
_builder.append(".nextName();");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("if(");
String _readerIdentifier_3 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_3, "\t");
_builder.append(".peek() == JsonToken.NULL) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
String _readerIdentifier_4 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_4, "\t\t");
_builder.append(".skipValue();");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("continue;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
int COUNTER = 0;
_builder.newLineIfNotEmpty();
{
ComplexTypeLiteral _literal = skipMember.getLiteral();
EList<Member> _members = _literal.getMembers();
for (final Member member : _members) {
_builder.append("\t");
Object _genBlock = this.genBlock(member, COUNTER = (COUNTER + 1));
_builder.append(_genBlock, "\t");
_builder.newLineIfNotEmpty();
}
}
{
if ((COUNTER > 0)) {
_builder.append("\t");
_builder.append("else {");
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
String _readerIdentifier_5 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_5, "\t\t");
_builder.append(".skipValue();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.append("}");
_builder.newLine();
_builder.newLine();
String _readerIdentifier_6 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_6, "");
_builder.append(".endObject();");
_builder.newLineIfNotEmpty();
return _builder;
}
use of com.robotoworks.mechanoid.net.generator.ImportHelper in project mechanoid by robotoworks.
the class JsonWriterStatementGenerator method _genStatementForGenericListType.
protected CharSequence _genStatementForGenericListType(final TypedMember member, final GenericListType type, final IntrinsicType itemType) {
StringConcatenation _builder = new StringConcatenation();
ImportHelper _imports = this.getImports();
_imports.addImport("com.robotoworks.mechanoid.internal.util.JsonUtil");
_builder.newLineIfNotEmpty();
ImportHelper _imports_1 = this.getImports();
_imports_1.addImport("java.util.List");
_builder.newLineIfNotEmpty();
_builder.append("if(");
String _getMethodName = ModelExtensions.toGetMethodName(member);
String _subjectIdentifier = this.getSubjectIdentifier();
String _memberize = ModelExtensions.memberize(_getMethodName, _subjectIdentifier);
_builder.append(_memberize, "");
_builder.append("() != null) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
String _writerIdentifier = this.getWriterIdentifier();
_builder.append(_writerIdentifier, "\t");
_builder.append(".name(\"");
String _name = member.getName();
_builder.append(_name, "\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("JsonUtil.write");
String _boxedTypeSignature = ModelExtensions.getBoxedTypeSignature(itemType);
_builder.append(_boxedTypeSignature, "\t");
_builder.append("List(");
String _writerIdentifier_1 = this.getWriterIdentifier();
_builder.append(_writerIdentifier_1, "\t");
_builder.append(", ");
String _getMethodName_1 = ModelExtensions.toGetMethodName(member);
String _subjectIdentifier_1 = this.getSubjectIdentifier();
String _memberize_1 = ModelExtensions.memberize(_getMethodName_1, _subjectIdentifier_1);
_builder.append(_memberize_1, "\t");
_builder.append("());");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
return _builder;
}
use of com.robotoworks.mechanoid.net.generator.ImportHelper in project mechanoid by robotoworks.
the class JsonWriterStatementGenerator method _genStatementForUserTypeGenericList.
protected CharSequence _genStatementForUserTypeGenericList(final TypedMember member, final GenericListType type, final UserType itemType, final ComplexTypeDeclaration decl) {
StringConcatenation _builder = new StringConcatenation();
ImportHelper _imports = this.getImports();
_imports.addImport("java.util.List");
_builder.newLineIfNotEmpty();
_builder.append("if(");
String _getMethodName = ModelExtensions.toGetMethodName(member);
String _subjectIdentifier = this.getSubjectIdentifier();
String _memberize = ModelExtensions.memberize(_getMethodName, _subjectIdentifier);
_builder.append(_memberize, "");
_builder.append("() != null) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
String _writerIdentifier = this.getWriterIdentifier();
_builder.append(_writerIdentifier, "\t");
_builder.append(".name(\"");
String _name = member.getName();
_builder.append(_name, "\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
String _providerIdentifier = this.getProviderIdentifier();
_builder.append(_providerIdentifier, "\t");
_builder.append(".get(");
String _innerSignature = ModelExtensions.innerSignature(type);
_builder.append(_innerSignature, "\t");
_builder.append(".class).writeList(");
String _writerIdentifier_1 = this.getWriterIdentifier();
_builder.append(_writerIdentifier_1, "\t");
_builder.append(", ");
String _getMethodName_1 = ModelExtensions.toGetMethodName(member);
String _subjectIdentifier_1 = this.getSubjectIdentifier();
String _memberize_1 = ModelExtensions.memberize(_getMethodName_1, _subjectIdentifier_1);
_builder.append(_memberize_1, "\t");
_builder.append("());");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
return _builder;
}
use of com.robotoworks.mechanoid.net.generator.ImportHelper in project mechanoid by robotoworks.
the class JsonWriterStatementGenerator method _genStatementForUserTypeGenericList.
protected CharSequence _genStatementForUserTypeGenericList(final TypedMember member, final GenericListType type, final UserType itemType, final EnumTypeDeclaration decl) {
StringConcatenation _builder = new StringConcatenation();
ImportHelper _imports = this.getImports();
_imports.addImport("java.util.List");
_builder.newLineIfNotEmpty();
ImportHelper _imports_1 = this.getImports();
_imports_1.addImport("java.util.ArrayList");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("if(");
String _getMethodName = ModelExtensions.toGetMethodName(member);
String _subjectIdentifier = this.getSubjectIdentifier();
String _memberize = ModelExtensions.memberize(_getMethodName, _subjectIdentifier);
_builder.append(_memberize, "");
_builder.append("() != null) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
String _writerIdentifier = this.getWriterIdentifier();
_builder.append(_writerIdentifier, "\t");
_builder.append(".name(\"");
String _name = member.getName();
_builder.append(_name, "\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
String _writerIdentifier_1 = this.getWriterIdentifier();
_builder.append(_writerIdentifier_1, "\t");
_builder.append(".beginArray();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("for(");
Type _type = member.getType();
String _innerSignature = ModelExtensions.innerSignature(_type);
_builder.append(_innerSignature, "\t");
_builder.append(" element : ");
String _getMethodName_1 = ModelExtensions.toGetMethodName(member);
String _subjectIdentifier_1 = this.getSubjectIdentifier();
String _memberize_1 = ModelExtensions.memberize(_getMethodName_1, _subjectIdentifier_1);
_builder.append(_memberize_1, "\t");
_builder.append("()) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
String _writerIdentifier_2 = this.getWriterIdentifier();
_builder.append(_writerIdentifier_2, "\t\t");
_builder.append(".value(element.toString());");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
String _writerIdentifier_3 = this.getWriterIdentifier();
_builder.append(_writerIdentifier_3, "\t");
_builder.append(".endArray();");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
return _builder;
}
use of com.robotoworks.mechanoid.net.generator.ImportHelper in project mechanoid by robotoworks.
the class JsonReaderStatementGenerator method genReadComplexTypeLiteralForMembers.
public CharSequence genReadComplexTypeLiteralForMembers(final EList<Member> members) {
StringConcatenation _builder = new StringConcatenation();
ImportHelper _imports = this.getImports();
_imports.addImport("com.robotoworks.mechanoid.internal.util.JsonToken");
_builder.newLineIfNotEmpty();
String _readerIdentifier = this.getReaderIdentifier();
_builder.append(_readerIdentifier, "");
_builder.append(".beginObject();");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("while(");
String _readerIdentifier_1 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_1, "");
_builder.append(".hasNext()) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("String name = ");
String _readerIdentifier_2 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_2, "\t");
_builder.append(".nextName();");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("if(");
String _readerIdentifier_3 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_3, "\t");
_builder.append(".peek() == JsonToken.NULL) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
String _readerIdentifier_4 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_4, "\t\t");
_builder.append(".skipValue();");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("continue;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.newLine();
_builder.append("\t");
int COUNTER = 0;
_builder.newLineIfNotEmpty();
{
for (final Member member : members) {
_builder.append("\t");
CharSequence _genBlock = this.genBlock(member, COUNTER = (COUNTER + 1));
_builder.append(_genBlock, "\t");
_builder.newLineIfNotEmpty();
}
}
{
if ((COUNTER > 0)) {
_builder.append("\t");
_builder.append("else {");
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
String _readerIdentifier_5 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_5, "\t\t");
_builder.append(".skipValue();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.append("}");
_builder.newLine();
_builder.newLine();
String _readerIdentifier_6 = this.getReaderIdentifier();
_builder.append(_readerIdentifier_6, "");
_builder.append(".endObject();");
_builder.newLineIfNotEmpty();
return _builder;
}
Aggregations