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.
com.reprezen.genflow.rapidml.xsd.XMLSchemaHelper Maven / Gradle / Ivy
/**
* Copyright © 2013, 2016 Modelsolv, Inc.
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains the property
* of ModelSolv, Inc. See the file license.html in the root directory of
* this project for further information.
*/
package com.reprezen.genflow.rapidml.xsd;
import com.google.common.base.Objects;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.reprezen.genflow.api.zenmodel.util.CommonServices;
import com.reprezen.genflow.common.xtend.ZenModelHelper;
import com.reprezen.genflow.rapidml.xsd.Helpers;
import com.reprezen.genflow.rapidml.xsd.ParamsHelper;
import com.reprezen.genflow.rapidml.xsd.TraceHelper;
import com.reprezen.genflow.rapidml.xsd.XMLSchemaGenTemplate;
import com.reprezen.rapidml.Constraint;
import com.reprezen.rapidml.DataModel;
import com.reprezen.rapidml.Documentable;
import com.reprezen.rapidml.Element;
import com.reprezen.rapidml.Enumeration;
import com.reprezen.rapidml.Feature;
import com.reprezen.rapidml.ImportDeclaration;
import com.reprezen.rapidml.LengthConstraint;
import com.reprezen.rapidml.Method;
import com.reprezen.rapidml.PrimitiveType;
import com.reprezen.rapidml.PropertyRealization;
import com.reprezen.rapidml.ReferenceElement;
import com.reprezen.rapidml.RegExConstraint;
import com.reprezen.rapidml.ResourceAPI;
import com.reprezen.rapidml.ResourceDefinition;
import com.reprezen.rapidml.ServiceDataResource;
import com.reprezen.rapidml.SimpleType;
import com.reprezen.rapidml.SingleValueType;
import com.reprezen.rapidml.Structure;
import com.reprezen.rapidml.TypedMessage;
import com.reprezen.rapidml.UserDefinedType;
import com.reprezen.rapidml.ValueRangeConstraint;
import com.reprezen.rapidml.ZenModel;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
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.ListExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
@SuppressWarnings("all")
public class XMLSchemaHelper {
@Extension
private ZenModelHelper zenModelHelper;
@Extension
private ParamsHelper paramsHelper;
@Extension
private TraceHelper traceHelper;
public XMLSchemaHelper(final Helpers helpers) {
ZenModelHelper _zenModelHelper = helpers.getZenModelHelper();
this.zenModelHelper = _zenModelHelper;
ParamsHelper _paramsHelper = helpers.getParamsHelper();
this.paramsHelper = _paramsHelper;
TraceHelper _traceHelper = helpers.getTraceHelper();
this.traceHelper = _traceHelper;
}
public String escapeXml(final String source) {
String _replaceAll = source.replaceAll("&", "&");
String _replaceAll_1 = _replaceAll.replaceAll("\"", """);
String _replaceAll_2 = _replaceAll_1.replaceAll("<", "<");
String _replaceAll_3 = _replaceAll_2.replaceAll(">", ">");
return _replaceAll_3.replaceAll("\'", "'");
}
public T getEContainer(final EObject ele, final Class type) {
return CommonServices.getContainerOfType(ele, type);
}
public Collection putAll(final Iterable iterable, final Class _class) {
final Collection result = new LinkedList();
final Consumer _function = (T it) -> {
result.add(it);
};
iterable.forEach(_function);
return result;
}
public ZenModel zenModel(final EObject obj) {
return this.getEContainer(obj, ZenModel.class);
}
protected String _namespace(final DataModel dataModel) {
ZenModel _zenModel = this.zenModel(dataModel);
String _schemaRoot = this.schemaRoot(_zenModel);
String _name = dataModel.getName();
String _lowerCase = _name.toLowerCase();
return (_schemaRoot + _lowerCase);
}
protected String _namespace(final ResourceAPI resourceAPI) {
ZenModel _zenModel = this.zenModel(resourceAPI);
String _schemaRoot = this.schemaRoot(_zenModel);
String _name = resourceAPI.getName();
String _lowerCase = _name.toLowerCase();
return (_schemaRoot + _lowerCase);
}
public String schemaRoot(final ZenModel zenModel) {
String _xblockexpression = null;
{
String _xifexpression = null;
String _namespace = zenModel.getNamespace();
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_namespace);
if (_isNullOrEmpty) {
_xifexpression = "http://modelsolv.com/reprezen/schemas";
} else {
String _namespace_1 = zenModel.getNamespace();
String _reverseNamespace = this.reverseNamespace(_namespace_1);
_xifexpression = ("http://" + _reverseNamespace);
}
final String uriFragment = _xifexpression;
String _name = zenModel.getName();
String _lowerCase = _name.toLowerCase();
String _plus = ((uriFragment + "/") + _lowerCase);
_xblockexpression = (_plus + "/");
}
return _xblockexpression;
}
public String reverseNamespace(final String namespace) {
String _xblockexpression = null;
{
final int idx = namespace.indexOf(".");
String _xifexpression = null;
if ((idx == (-1))) {
_xifexpression = namespace;
} else {
Splitter _on = Splitter.on(".");
Iterable _split = _on.split(namespace);
List _list = IterableExtensions.toList(_split);
List _reverse = Lists.reverse(_list);
_xifexpression = IterableExtensions.join(_reverse, ".");
}
_xblockexpression = _xifexpression;
}
return _xblockexpression;
}
public String nsPrefix(final DataModel dataModel, final ResourceAPI resourceAPI) {
String _xifexpression = null;
if ((dataModel != null)) {
String _xifexpression_1 = null;
ZenModel _zenModel = this.zenModel(resourceAPI);
ZenModel _zenModel_1 = this.zenModel(dataModel);
boolean _equals = Objects.equal(_zenModel, _zenModel_1);
if (_equals) {
String _name = dataModel.getName();
_xifexpression_1 = StringExtensions.toFirstLower(_name);
} else {
String _xblockexpression = null;
{
ZenModel _zenModel_2 = this.zenModel(resourceAPI);
final String alias = this.getAliasForDataModel(_zenModel_2, dataModel);
String _xifexpression_2 = null;
boolean _isNullOrEmpty = Strings.isNullOrEmpty(alias);
if (_isNullOrEmpty) {
_xifexpression_2 = this.getShortestUniqueName(dataModel, resourceAPI);
} else {
_xifexpression_2 = alias;
}
_xblockexpression = _xifexpression_2;
}
_xifexpression_1 = _xblockexpression;
}
_xifexpression = _xifexpression_1;
}
return _xifexpression;
}
protected String _nsPrefix(final ResourceAPI resourceAPI) {
String _xifexpression = null;
if ((resourceAPI != null)) {
String _name = resourceAPI.getName();
String _lowerCase = _name.toLowerCase();
_xifexpression = (_lowerCase + "");
}
return _xifexpression;
}
protected String _nsPrefix(final ServiceDataResource dataResource) {
ResourceAPI _interface = this.getInterface(dataResource);
return this.nsPrefix(_interface);
}
public String xsdFileName(final DataModel dataModel, final ZenModel zenModel) {
String _xifexpression = null;
ZenModel _zenModel = this.zenModel(dataModel);
boolean _equals = Objects.equal(zenModel, _zenModel);
if (_equals) {
String _name = dataModel.getName();
String _firstLower = StringExtensions.toFirstLower(_name);
_xifexpression = (_firstLower + ".xsd");
} else {
String _xblockexpression = null;
{
final ZenModel model = this.zenModel(dataModel);
String _name_1 = model.getName();
String _firstLower_1 = StringExtensions.toFirstLower(_name_1);
String _plus = (_firstLower_1 + "-");
String _name_2 = dataModel.getName();
String _firstLower_2 = StringExtensions.toFirstLower(_name_2);
String _plus_1 = (_plus + _firstLower_2);
final String woNsName = (_plus_1 + ".xsd");
String _xifexpression_1 = null;
String _namespace = model.getNamespace();
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_namespace);
if (_isNullOrEmpty) {
_xifexpression_1 = woNsName;
} else {
String _namespace_1 = model.getNamespace();
String _firstLower_3 = StringExtensions.toFirstLower(_namespace_1);
String _replaceAll = _firstLower_3.replaceAll("\\.", "-");
String _plus_2 = (_replaceAll + "-");
_xifexpression_1 = (_plus_2 + woNsName);
}
_xblockexpression = _xifexpression_1;
}
_xifexpression = _xblockexpression;
}
return _xifexpression;
}
public String xsdFileName(final ResourceAPI resourceAPI) {
String _name = resourceAPI.getName();
String _firstLower = StringExtensions.toFirstLower(_name);
return (_firstLower + ".xsd");
}
protected String _typeName(final TypedMessage message) {
String _switchResult = null;
XMLSchemaGenTemplate.TypeNamingMethod _typeNamingMethod = this.paramsHelper.typeNamingMethod();
if (_typeNamingMethod != null) {
switch (_typeNamingMethod) {
case SIMPLE_NAME:
_switchResult = CommonServices.getMessageTypeName(message);
break;
case FULLY_QUALIFIED_NAME:
String _fqName = this.traceHelper.getFqName(message);
_switchResult = StringExtensions.toFirstUpper(_fqName);
break;
default:
break;
}
}
final String name = _switchResult;
this.traceHelper.setTypeNameInTrace(message, name);
return name;
}
protected String _typeName(final Structure structure) {
String _switchResult = null;
XMLSchemaGenTemplate.TypeNamingMethod _typeNamingMethod = this.paramsHelper.typeNamingMethod();
if (_typeNamingMethod != null) {
switch (_typeNamingMethod) {
case SIMPLE_NAME:
String _name = structure.getName();
_switchResult = StringExtensions.toFirstUpper(_name);
break;
case FULLY_QUALIFIED_NAME:
String _fqName = this.traceHelper.getFqName(structure);
_switchResult = StringExtensions.toFirstUpper(_fqName);
break;
default:
break;
}
}
final String name = _switchResult;
this.traceHelper.setTypeNameInTrace(structure, name);
return name;
}
protected String _typeName(final Enumeration enumeration) {
String _switchResult = null;
XMLSchemaGenTemplate.TypeNamingMethod _typeNamingMethod = this.paramsHelper.typeNamingMethod();
if (_typeNamingMethod != null) {
switch (_typeNamingMethod) {
case SIMPLE_NAME:
_switchResult = enumeration.getName();
break;
case FULLY_QUALIFIED_NAME:
String _fqName = this.traceHelper.getFqName(enumeration);
_switchResult = StringExtensions.toFirstUpper(_fqName);
break;
default:
break;
}
}
final String name = _switchResult;
this.traceHelper.setTypeNameInTrace(enumeration, name);
return name;
}
protected String _typeName(final UserDefinedType type) {
String _switchResult = null;
XMLSchemaGenTemplate.TypeNamingMethod _typeNamingMethod = this.paramsHelper.typeNamingMethod();
if (_typeNamingMethod != null) {
switch (_typeNamingMethod) {
case SIMPLE_NAME:
_switchResult = type.getName();
break;
case FULLY_QUALIFIED_NAME:
String _fqName = this.traceHelper.getFqName(type);
_switchResult = StringExtensions.toFirstUpper(_fqName);
break;
default:
break;
}
}
final String name = _switchResult;
this.traceHelper.setTypeNameInTrace(type, name);
return name;
}
protected String _typeName(final PrimitiveType type) {
return type.getName();
}
protected String _typeName(final ServiceDataResource dataResource) {
String _switchResult = null;
XMLSchemaGenTemplate.TypeNamingMethod _typeNamingMethod = this.paramsHelper.typeNamingMethod();
if (_typeNamingMethod != null) {
switch (_typeNamingMethod) {
case SIMPLE_NAME:
String _name = dataResource.getName();
_switchResult = StringExtensions.toFirstUpper(_name);
break;
case FULLY_QUALIFIED_NAME:
String _fqName = this.traceHelper.getFqName(dataResource);
_switchResult = StringExtensions.toFirstUpper(_fqName);
break;
default:
break;
}
}
final String name = _switchResult;
this.traceHelper.setTypeNameInTrace(dataResource, name);
return name;
}
public String extend(final String baseName, final List extends ReferenceElement> path) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(baseName, "");
_builder.append("_");
final Function1 _function = (ReferenceElement it) -> {
return it.getName();
};
List _map = ListExtensions.map(path, _function);
String _join = IterableExtensions.join(_map, "_");
_builder.append(_join, "");
return _builder.toString();
}
protected String _getRootElementName(final Structure structure) {
String _typeName = this.typeName(structure);
final String name = StringExtensions.toFirstLower(_typeName);
this.traceHelper.setRootElementInTrace(structure, name);
return name;
}
protected String _getRootElementName(final ServiceDataResource resource) {
String _typeName = this.typeName(resource);
final String name = StringExtensions.toFirstLower(_typeName);
this.traceHelper.setRootElementInTrace(resource, name);
return name;
}
protected String _getRootElementName(final TypedMessage message) {
String _typeName = this.typeName(message);
final String name = StringExtensions.toFirstLower(_typeName);
this.traceHelper.setRootElementInTrace(message, name);
return name;
}
public String getElementName(final Element element) {
String _switchResult = null;
boolean _matched = false;
if (!_matched) {
if (element instanceof Feature) {
_matched=true;
_switchResult = ((Feature)element).getName();
}
}
if (!_matched) {
if (element instanceof ReferenceElement) {
_matched=true;
_switchResult = ((ReferenceElement)element).getName();
}
}
final String name = StringExtensions.toFirstLower(_switchResult);
this.traceHelper.setElementNameInTrace(element, name);
return name;
}
public String getElementName(final PropertyRealization property) {
Feature _baseProperty = property.getBaseProperty();
return this.getElementName(_baseProperty);
}
public String getAttributeName(final Element element) {
String _switchResult = null;
boolean _matched = false;
if (!_matched) {
if (element instanceof Feature) {
_matched=true;
_switchResult = ((Feature)element).getName();
}
}
if (!_matched) {
if (element instanceof ReferenceElement) {
_matched=true;
_switchResult = ((ReferenceElement)element).getName();
}
}
final String name = StringExtensions.toFirstLower(_switchResult);
this.traceHelper.setAttributeNameInTrace(element, name);
return name;
}
public String getAttributeName(final PropertyRealization property) {
Feature _baseProperty = property.getBaseProperty();
return this.getAttributeName(_baseProperty);
}
protected String _typeQName(final TypedMessage message) {
String _xblockexpression = null;
{
final ResourceDefinition resourceType = message.getResourceType();
ServiceDataResource _serviceDataResource = this.toServiceDataResource(resourceType);
_xblockexpression = this.typeQName(_serviceDataResource);
}
return _xblockexpression;
}
protected String _typeQName(final ServiceDataResource dataResource) {
String _xifexpression = null;
if ((dataResource == null)) {
_xifexpression = null;
} else {
String _nsPrefix = this.nsPrefix(dataResource);
String _plus = (_nsPrefix + ":");
String _typeName = this.typeName(dataResource);
_xifexpression = (_plus + _typeName);
}
return _xifexpression;
}
private ServiceDataResource toServiceDataResource(final ResourceDefinition resource) {
ServiceDataResource _xifexpression = null;
if ((resource instanceof ServiceDataResource)) {
_xifexpression = ((ServiceDataResource)resource);
} else {
_xifexpression = null;
}
return _xifexpression;
}
protected DataModel getInterfaceDataModel(final Structure complexType) {
EObject _eContainer = complexType.eContainer();
return ((DataModel) _eContainer);
}
public ResourceAPI getInterface(final ServiceDataResource dataResource) {
ResourceAPI _xifexpression = null;
if ((dataResource == null)) {
_xifexpression = null;
} else {
_xifexpression = this.getEContainer(dataResource, ResourceAPI.class);
}
return _xifexpression;
}
public Iterable getUsedTypes(final ZenModel zenModel) {
return CommonServices.getUsedSimpleTypes(zenModel);
}
public Iterable getUsedTypes(final ResourceAPI resourceAPI) {
return CommonServices.getUsedSimpleTypes(resourceAPI);
}
public String getAliasForDataModel(final ZenModel zenModel, final DataModel dataModel) {
ImportDeclaration _importDeclaration = this.getImportDeclaration(zenModel, dataModel);
return _importDeclaration.getAlias();
}
public ImportDeclaration getImportDeclaration(final ZenModel zenModel, final DataModel dataModel) {
ImportDeclaration _xifexpression = null;
ZenModel _zenModel = this.zenModel(dataModel);
boolean _equals = Objects.equal(zenModel, _zenModel);
if (_equals) {
_xifexpression = null;
} else {
EList _imports = zenModel.getImports();
final Function1 _function = (ImportDeclaration it) -> {
String _importedNamespace = it.getImportedNamespace();
String _fQN = this.getFQN(dataModel);
return Boolean.valueOf(Objects.equal(_importedNamespace, _fQN));
};
_xifexpression = IterableExtensions.findFirst(_imports, _function);
}
return _xifexpression;
}
public String getFQN(final DataModel dataModel) {
String _xblockexpression = null;
{
final ZenModel zenModel = this.zenModel(dataModel);
String _name = zenModel.getName();
String _plus = (_name + ".");
String _name_1 = dataModel.getName();
final String woNsName = (_plus + _name_1);
String _xifexpression = null;
String _namespace = zenModel.getNamespace();
boolean _isNullOrEmpty = Strings.isNullOrEmpty(_namespace);
if (_isNullOrEmpty) {
_xifexpression = woNsName;
} else {
String _namespace_1 = zenModel.getNamespace();
String _plus_1 = (_namespace_1 + ".");
_xifexpression = (_plus_1 + woNsName);
}
_xblockexpression = _xifexpression;
}
return _xblockexpression;
}
public String getShortestUniqueName(final DataModel dataModel, final ResourceAPI resourceAPI) {
String result = null;
Iterable _usedDataModels = this.getUsedDataModels(resourceAPI);
final Function1 _function = (DataModel it) -> {
boolean _and = false;
boolean _or = false;
ZenModel _zenModel = this.zenModel(resourceAPI);
ZenModel _zenModel_1 = this.zenModel(it);
boolean _equals = Objects.equal(_zenModel, _zenModel_1);
if (_equals) {
_or = true;
} else {
ZenModel _zenModel_2 = this.zenModel(resourceAPI);
ImportDeclaration _importDeclaration = this.getImportDeclaration(_zenModel_2, it);
String _alias = _importDeclaration.getAlias();
boolean _tripleEquals = (_alias == null);
_or = _tripleEquals;
}
if (!_or) {
_and = false;
} else {
String _name = it.getName();
String _name_1 = dataModel.getName();
boolean _equals_1 = Objects.equal(_name, _name_1);
_and = _equals_1;
}
return Boolean.valueOf(_and);
};
Iterable _filter = IterableExtensions.filter(_usedDataModels, _function);
final Function1 _function_1 = (DataModel it) -> {
return Boolean.valueOf((!Objects.equal(it, dataModel)));
};
Iterable _filter_1 = IterableExtensions.filter(_filter, _function_1);
Set dataModels = IterableExtensions.toSet(_filter_1);
boolean _isEmpty = dataModels.isEmpty();
if (_isEmpty) {
String _name = dataModel.getName();
result = _name;
} else {
final Function1 _function_2 = (DataModel it) -> {
ZenModel _zenModel = this.zenModel(it);
String _name_1 = _zenModel.getName();
ZenModel _zenModel_1 = this.zenModel(dataModel);
String _name_2 = _zenModel_1.getName();
return Boolean.valueOf(Objects.equal(_name_1, _name_2));
};
boolean _exists = IterableExtensions.exists(dataModels, _function_2);
boolean _not = (!_exists);
if (_not) {
ZenModel _zenModel = this.zenModel(dataModel);
String _name_1 = _zenModel.getName();
String _plus = (_name_1 + ".");
String _name_2 = dataModel.getName();
String _plus_1 = (_plus + _name_2);
result = _plus_1;
} else {
String _fQN = this.getFQN(dataModel);
result = _fQN;
}
}
return result;
}
public String getBaseTypeName(final UserDefinedType userDefinedType) {
String _xifexpression = null;
SimpleType _baseType = userDefinedType.getBaseType();
if ((_baseType instanceof PrimitiveType)) {
_xifexpression = "xs:";
} else {
_xifexpression = "";
}
final String prefix = _xifexpression;
SimpleType _baseType_1 = userDefinedType.getBaseType();
String _name = _baseType_1.getName();
return (prefix + _name);
}
protected Iterable _getUsedDataModels(final ResourceAPI resourceAPI) {
Iterable _usedTypes = this.getUsedTypes(resourceAPI);
final Function1 _function = (SingleValueType it) -> {
return this.getEContainer(it, DataModel.class);
};
Iterable _map = IterableExtensions.map(_usedTypes, _function);
final Function1 _function_1 = (DataModel it) -> {
return Boolean.valueOf((it != null));
};
Iterable _filter = IterableExtensions.filter(_map, _function_1);
return IterableExtensions.toSet(_filter);
}
protected Iterable _getUsedDataModels(final ZenModel zenModel) {
EList _resourceAPIs = zenModel.getResourceAPIs();
final Function1> _function = (ResourceAPI it) -> {
return this.getUsedDataModels(it);
};
List> _map = ListExtensions.>map(_resourceAPIs, _function);
Iterable _flatten = Iterables.concat(_map);
return IterableExtensions.toSet(_flatten);
}
public ResourceDefinition getParentResourceDefinition(final TypedMessage message) {
Method _eContainer = this.getEContainer(message, Method.class);
return this.getEContainer(_eContainer, ResourceDefinition.class);
}
public String generateXSDDoc(final Documentable doc) {
String _xblockexpression = null;
{
final String docText = this.zenModelHelper.getDocumentation(doc);
String _replaceAll = docText.replaceAll("[\r\n]+", " ");
String _replaceAll_1 = _replaceAll.replaceAll("[\n]+", " ");
String _replaceAll_2 = _replaceAll_1.replaceAll("([\"\\\\])",
"\\\\$1");
final String escapedDoc = _replaceAll_2.trim();
String _xifexpression = null;
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(escapedDoc);
boolean _not = (!_isNullOrEmpty);
if (_not) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("");
_builder.newLine();
_builder.append("\t");
_builder.append("");
_builder.newLine();
_builder.append("\t\t");
_builder.append("");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(" ");
_builder.newLine();
_builder.append(" ");
_builder.newLine();
_xifexpression = _builder.toString();
}
_xblockexpression = _xifexpression;
}
return _xblockexpression;
}
public CharSequence generateRestriction(final String baseTypeName, final Iterable constraints) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("");
_builder.newLineIfNotEmpty();
{
boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(constraints);
boolean _not = (!_isNullOrEmpty);
if (_not) {
{
boolean _hasElements = false;
for(final Constraint constraint : constraints) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate("", "");
}
{
if ((constraint instanceof LengthConstraint)) {
{
boolean _and = false;
int _maxLength = ((LengthConstraint)constraint).getMaxLength();
boolean _notEquals = (_maxLength != 0);
if (!_notEquals) {
_and = false;
} else {
int _maxLength_1 = ((LengthConstraint)constraint).getMaxLength();
int _minLength = ((LengthConstraint)constraint).getMinLength();
boolean _equals = (_maxLength_1 == _minLength);
_and = _equals;
}
if (_and) {
_builder.append(" ");
_builder.newLineIfNotEmpty();
} else {
{
int _minLength_2 = ((LengthConstraint)constraint).getMinLength();
boolean _notEquals_1 = (_minLength_2 != 0);
if (_notEquals_1) {
_builder.append(" ");
_builder.newLineIfNotEmpty();
}
}
{
int _maxLength_2 = ((LengthConstraint)constraint).getMaxLength();
boolean _notEquals_2 = (_maxLength_2 != 0);
if (_notEquals_2) {
_builder.append(" ");
_builder.newLineIfNotEmpty();
}
}
}
}
}
}
{
if ((constraint instanceof RegExConstraint)) {
_builder.append(" ");
_builder.newLineIfNotEmpty();
}
}
{
if ((constraint instanceof ValueRangeConstraint)) {
{
boolean _isMinValueExclusive = ((ValueRangeConstraint)constraint).isMinValueExclusive();
if (_isMinValueExclusive) {
_builder.append(" ");
_builder.newLineIfNotEmpty();
} else {
String _minValue_1 = ((ValueRangeConstraint)constraint).getMinValue();
boolean _tripleNotEquals = (_minValue_1 != null);
if (_tripleNotEquals) {
_builder.append(" ");
_builder.newLineIfNotEmpty();
}
}
}
{
boolean _isMaxValueExclusive = ((ValueRangeConstraint)constraint).isMaxValueExclusive();
if (_isMaxValueExclusive) {
_builder.append(" ");
_builder.newLineIfNotEmpty();
} else {
String _maxValue_1 = ((ValueRangeConstraint)constraint).getMaxValue();
boolean _tripleNotEquals_1 = (_maxValue_1 != null);
if (_tripleNotEquals_1) {
_builder.append(" ");
_builder.newLineIfNotEmpty();
}
}
}
}
}
}
}
}
}
_builder.append(" ");
_builder.newLine();
return _builder;
}
public String namespace(final EObject resourceAPI) {
if (resourceAPI instanceof ResourceAPI) {
return _namespace((ResourceAPI)resourceAPI);
} else if (resourceAPI instanceof DataModel) {
return _namespace((DataModel)resourceAPI);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.asList(resourceAPI).toString());
}
}
public String nsPrefix(final EObject dataResource) {
if (dataResource instanceof ServiceDataResource) {
return _nsPrefix((ServiceDataResource)dataResource);
} else if (dataResource instanceof ResourceAPI) {
return _nsPrefix((ResourceAPI)dataResource);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.asList(dataResource).toString());
}
}
public String typeName(final EObject type) {
if (type instanceof PrimitiveType) {
return _typeName((PrimitiveType)type);
} else if (type instanceof UserDefinedType) {
return _typeName((UserDefinedType)type);
} else if (type instanceof Enumeration) {
return _typeName((Enumeration)type);
} else if (type instanceof ServiceDataResource) {
return _typeName((ServiceDataResource)type);
} else if (type instanceof Structure) {
return _typeName((Structure)type);
} else if (type instanceof TypedMessage) {
return _typeName((TypedMessage)type);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.asList(type).toString());
}
}
public String getRootElementName(final EObject resource) {
if (resource instanceof ServiceDataResource) {
return _getRootElementName((ServiceDataResource)resource);
} else if (resource instanceof Structure) {
return _getRootElementName((Structure)resource);
} else if (resource instanceof TypedMessage) {
return _getRootElementName((TypedMessage)resource);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.asList(resource).toString());
}
}
public String typeQName(final EObject dataResource) {
if (dataResource instanceof ServiceDataResource) {
return _typeQName((ServiceDataResource)dataResource);
} else if (dataResource instanceof TypedMessage) {
return _typeQName((TypedMessage)dataResource);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.asList(dataResource).toString());
}
}
public Iterable getUsedDataModels(final EObject resourceAPI) {
if (resourceAPI instanceof ResourceAPI) {
return _getUsedDataModels((ResourceAPI)resourceAPI);
} else if (resourceAPI instanceof ZenModel) {
return _getUsedDataModels((ZenModel)resourceAPI);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.asList(resourceAPI).toString());
}
}
}