Search in sources :

Example 6 with ImportHelper

use of com.robotoworks.mechanoid.net.generator.ImportHelper in project mechanoid by robotoworks.

the class JsonReaderStatementGenerator 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();
    ImportHelper _imports_1 = this.getImports();
    _imports_1.addImport("java.util.ArrayList");
    _builder.newLineIfNotEmpty();
    String _signature = ModelExtensions.signature(type);
    _builder.append(_signature, "");
    _builder.append(" entityMember = new ArrayList<");
    String _innerSignature = ModelExtensions.innerSignature(type);
    _builder.append(_innerSignature, "");
    _builder.append(">();");
    _builder.newLineIfNotEmpty();
    String _providerIdentifier = this.getProviderIdentifier();
    _builder.append(_providerIdentifier, "");
    _builder.append(".get(");
    String _innerSignature_1 = ModelExtensions.innerSignature(type);
    _builder.append(_innerSignature_1, "");
    _builder.append(".class).readList(");
    String _readerIdentifier = this.getReaderIdentifier();
    _builder.append(_readerIdentifier, "");
    _builder.append(", entityMember);");
    _builder.newLineIfNotEmpty();
    String _setMethodName = ModelExtensions.toSetMethodName(member);
    String _subjectIdentifier = this.getSubjectIdentifier();
    String _memberize = ModelExtensions.memberize(_setMethodName, _subjectIdentifier);
    _builder.append(_memberize, "");
    _builder.append("(entityMember);");
    _builder.newLineIfNotEmpty();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ImportHelper(com.robotoworks.mechanoid.net.generator.ImportHelper)

Example 7 with ImportHelper

use of com.robotoworks.mechanoid.net.generator.ImportHelper in project mechanoid by robotoworks.

the class JsonReaderStatementGenerator 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();
    ImportHelper _imports_2 = this.getImports();
    _imports_2.addImport("com.robotoworks.mechanoid.internal.util.JsonToken");
    _builder.newLineIfNotEmpty();
    String _signature = ModelExtensions.signature(type);
    _builder.append(_signature, "");
    _builder.append(" entityMember = new ArrayList");
    String _signature_1 = ModelExtensions.signature(type);
    _builder.append(_signature_1, "");
    _builder.append("();");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    String _readerIdentifier = this.getReaderIdentifier();
    _builder.append(_readerIdentifier, "");
    _builder.append(".beginArray();");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("while(");
    String _readerIdentifier_1 = this.getReaderIdentifier();
    _builder.append(_readerIdentifier_1, "");
    _builder.append(".hasNext()) {");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    String _innerSignature = ModelExtensions.innerSignature(type);
    _builder.append(_innerSignature, "\t");
    _builder.append(" element = ");
    String _innerSignature_1 = ModelExtensions.innerSignature(type);
    _builder.append(_innerSignature_1, "\t");
    _builder.append(".fromValue(");
    String _readerIdentifier_2 = this.getReaderIdentifier();
    _builder.append(_readerIdentifier_2, "\t");
    _builder.append(".");
    String _resolveJsonReaderMethodName = ModelExtensions.resolveJsonReaderMethodName(decl);
    _builder.append(_resolveJsonReaderMethodName, "\t");
    _builder.append("());");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("targetMember.add(element);");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    String _readerIdentifier_3 = this.getReaderIdentifier();
    _builder.append(_readerIdentifier_3, "");
    _builder.append(".endArray();");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    String _setMethodName = ModelExtensions.toSetMethodName(member);
    String _subjectIdentifier = this.getSubjectIdentifier();
    String _memberize = ModelExtensions.memberize(_setMethodName, _subjectIdentifier);
    _builder.append(_memberize, "");
    _builder.append("(entityMember);");
    _builder.newLineIfNotEmpty();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ImportHelper(com.robotoworks.mechanoid.net.generator.ImportHelper)

Example 8 with ImportHelper

use of com.robotoworks.mechanoid.net.generator.ImportHelper in project mechanoid by robotoworks.

the class JsonReaderStatementGenerator method _genStatementForGenericListType.

protected CharSequence _genStatementForGenericListType(final TypedMember member, final GenericListType type, final IntrinsicType itemType) {
    StringConcatenation _builder = new StringConcatenation();
    ImportHelper _imports = this.getImports();
    _imports.addImport("java.util.List");
    _builder.newLineIfNotEmpty();
    ImportHelper _imports_1 = this.getImports();
    _imports_1.addImport("com.robotoworks.mechanoid.internal.util.JsonUtil");
    _builder.newLineIfNotEmpty();
    _builder.append("List<");
    String _boxedTypeSignature = ModelExtensions.getBoxedTypeSignature(itemType);
    _builder.append(_boxedTypeSignature, "");
    _builder.append("> entityMember = JsonUtil.read");
    String _boxedTypeSignature_1 = ModelExtensions.getBoxedTypeSignature(itemType);
    _builder.append(_boxedTypeSignature_1, "");
    _builder.append("List(");
    String _readerIdentifier = this.getReaderIdentifier();
    _builder.append(_readerIdentifier, "");
    _builder.append(");");
    _builder.newLineIfNotEmpty();
    String _setMethodName = ModelExtensions.toSetMethodName(member);
    String _subjectIdentifier = this.getSubjectIdentifier();
    String _memberize = ModelExtensions.memberize(_setMethodName, _subjectIdentifier);
    _builder.append(_memberize, "");
    _builder.append("(entityMember);");
    _builder.newLineIfNotEmpty();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ImportHelper(com.robotoworks.mechanoid.net.generator.ImportHelper)

Example 9 with ImportHelper

use of com.robotoworks.mechanoid.net.generator.ImportHelper in project mechanoid by robotoworks.

the class JsonReaderStatementGenerator method genReadComplexTypeLiteral.

public CharSequence genReadComplexTypeLiteral(final ComplexTypeLiteral literal) {
    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.append("\t");
    _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();
    {
        EList<Member> _members = literal.getMembers();
        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;
}
Also used : EList(org.eclipse.emf.common.util.EList) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TypedMember(com.robotoworks.mechanoid.net.netModel.TypedMember) Member(com.robotoworks.mechanoid.net.netModel.Member) SkipMember(com.robotoworks.mechanoid.net.netModel.SkipMember) ImportHelper(com.robotoworks.mechanoid.net.generator.ImportHelper)

Aggregations

ImportHelper (com.robotoworks.mechanoid.net.generator.ImportHelper)9 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)9 Member (com.robotoworks.mechanoid.net.netModel.Member)3 SkipMember (com.robotoworks.mechanoid.net.netModel.SkipMember)3 TypedMember (com.robotoworks.mechanoid.net.netModel.TypedMember)3 EList (org.eclipse.emf.common.util.EList)2 ComplexTypeLiteral (com.robotoworks.mechanoid.net.netModel.ComplexTypeLiteral)1 GenericListType (com.robotoworks.mechanoid.net.netModel.GenericListType)1 IntrinsicType (com.robotoworks.mechanoid.net.netModel.IntrinsicType)1 Type (com.robotoworks.mechanoid.net.netModel.Type)1 UserType (com.robotoworks.mechanoid.net.netModel.UserType)1