All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.regnosys.rosetta.generator.golang.object.GolangModelObjectBoilerPlate Maven / Gradle / Ivy

There is a newer version: 11.22.1
Show newest version
package com.regnosys.rosetta.generator.golang.object;

import com.google.common.base.Objects;
import com.regnosys.rosetta.generator.golang.util.GolangTranslator;
import com.regnosys.rosetta.generator.object.ExpandedAttribute;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.StringExtensions;

@SuppressWarnings("all")
public class GolangModelObjectBoilerPlate {
  public CharSequence toAttributeName(final ExpandedAttribute attribute) {
    CharSequence _xifexpression = null;
    String _name = attribute.getName();
    boolean _equals = Objects.equal(_name, "type");
    if (_equals) {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("_type");
      _xifexpression = _builder;
    } else {
      _xifexpression = StringExtensions.toFirstUpper(attribute.getName());
    }
    return _xifexpression;
  }

  public String replaceTabsWithSpaces(final CharSequence code) {
    return code.toString().replace("\t", "  ");
  }

  public CharSequence toType(final ExpandedAttribute attribute) {
    StringConcatenation _builder = new StringConcatenation();
    {
      boolean _isMultiple = attribute.isMultiple();
      if (_isMultiple) {
        _builder.append("[]");
      }
    }
    CharSequence _rawType = this.toRawType(attribute);
    _builder.append(_rawType);
    return _builder;
  }

  private CharSequence toRawType(final ExpandedAttribute attribute) {
    CharSequence _xifexpression = null;
    boolean _hasMetas = attribute.hasMetas();
    boolean _not = (!_hasMetas);
    if (_not) {
      _xifexpression = GolangTranslator.toGOType(attribute.getType().getName());
    } else {
      CharSequence _xifexpression_1 = null;
      int _refIndex = attribute.refIndex();
      boolean _greaterEqualsThan = (_refIndex >= 0);
      if (_greaterEqualsThan) {
        CharSequence _xifexpression_2 = null;
        boolean _isType = attribute.getType().isType();
        if (_isType) {
          _xifexpression_2 = this.toReferenceWithMetaTypeName(attribute.getType().getName());
        } else {
          _xifexpression_2 = this.toBasicReferenceWithMetaTypeName(attribute.getType().getName());
        }
        _xifexpression_1 = _xifexpression_2;
      } else {
        _xifexpression_1 = this.toFieldWithMetaTypeName(attribute.getType().getName());
      }
      _xifexpression = _xifexpression_1;
    }
    return _xifexpression;
  }

  private CharSequence toReferenceWithMetaTypeName(final String type) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("ReferenceWithMeta");
    return _builder;
  }

  private CharSequence toBasicReferenceWithMetaTypeName(final String type) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("ReferenceWithMeta");
    return _builder;
  }

  private CharSequence toFieldWithMetaTypeName(final String type) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("FieldWithMeta");
    return _builder;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy