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

com.reprezen.genflow.swagger.doc.AttrDetails Maven / Gradle / Ivy

The newest version!
package com.reprezen.genflow.swagger.doc;

import com.reprezen.genflow.swagger.doc.AttributeHelper;
import com.reprezen.genflow.swagger.doc.HelperHelper;
import com.reprezen.genflow.swagger.doc.HtmlHelper;
import java.util.List;
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;

@SuppressWarnings("all")
public class AttrDetails {
  @Extension
  private AttributeHelper _attributeHelper = HelperHelper.getAttributeHelper();
  
  @Extension
  private HtmlHelper _htmlHelper = HelperHelper.getHtmlHelper();
  
  private Object obj;
  
  private final String id;
  
  public AttrDetails(final Object obj) {
    this.obj = obj;
    this.id = this._htmlHelper.getHtmlId(this);
  }
  
  public Object setObject(final Object obj) {
    return this.obj = obj;
  }
  
  public CharSequence details(final boolean topLevel) {
    CharSequence _xblockexpression = null;
    {
      final String details = this.getDetailRows();
      CharSequence _xifexpression = null;
      boolean _isEmpty = details.isEmpty();
      boolean _not = (!_isEmpty);
      if (_not) {
        CharSequence _xblockexpression_1 = null;
        {
          final CharSequence detailsTable = this.detailsTable(details);
          CharSequence _xifexpression_1 = null;
          if (topLevel) {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("
"); _builder.append(detailsTable); _builder.append("
"); _xifexpression_1 = _builder; } else { _xifexpression_1 = detailsTable; } _xblockexpression_1 = _xifexpression_1; } _xifexpression = _xblockexpression_1; } _xblockexpression = _xifexpression; } return _xblockexpression; } private CharSequence detailsTable(final String rows) { StringConcatenation _builder = new StringConcatenation(); _builder.append("
"); _builder.newLineIfNotEmpty(); _builder.append(" "); _builder.append(""); _builder.append(rows, " "); _builder.append("
"); _builder.newLineIfNotEmpty(); _builder.append("
"); _builder.newLine(); return _builder; } public CharSequence getInfoButton() { CharSequence _xifexpression = null; boolean _isEmpty = this.getDetailRows().isEmpty(); boolean _not = (!_isEmpty); if (_not) { _xifexpression = this.getInfoButton(this.id); } return _xifexpression; } private CharSequence getInfoButton(final String id) { StringConcatenation _builder = new StringConcatenation(); _builder.append(""); _builder.newLineIfNotEmpty(); _builder.append(" "); _builder.append(""); _builder.newLine(); _builder.append(" "); _builder.append(""); _builder.newLine(); _builder.append(""); _builder.newLine(); return _builder; } private String getDetailRows() { StringConcatenation _builder = new StringConcatenation(); CharSequence _detailRow = this.detailRow("Format"); _builder.append(_detailRow); _builder.newLineIfNotEmpty(); CharSequence _detailRow_1 = this.detailRow("Default"); _builder.append(_detailRow_1); _builder.newLineIfNotEmpty(); CharSequence _detailRow_2 = this.detailRow("Bounds"); _builder.append(_detailRow_2); _builder.newLineIfNotEmpty(); CharSequence _detailRow_3 = this.detailRow("Multiple Of"); _builder.append(_detailRow_3); _builder.newLineIfNotEmpty(); CharSequence _detailRow_4 = this.detailRow("Length"); _builder.append(_detailRow_4); _builder.newLineIfNotEmpty(); CharSequence _detailRow_5 = this.detailRow("Pattern"); _builder.append(_detailRow_5); _builder.newLineIfNotEmpty(); CharSequence _detailRow_6 = this.detailRow("Allowed Values"); _builder.append(_detailRow_6); _builder.newLineIfNotEmpty(); CharSequence _detailRow_7 = this.detailRow("Unique Values"); _builder.append(_detailRow_7); _builder.newLineIfNotEmpty(); CharSequence _detailRow_8 = this.detailRow("Example"); _builder.append(_detailRow_8); _builder.newLineIfNotEmpty(); return _builder.toString(); } private CharSequence detailRow(final String detailName) { CharSequence _xblockexpression = null; { String _switchResult = null; if (detailName != null) { switch (detailName) { case "Format": _switchResult = this._attributeHelper.getFormat(this.obj); break; case "Default": Object _defaultValue = this._attributeHelper.getDefaultValue(this.obj); String _string = null; if (_defaultValue!=null) { _string=_defaultValue.toString(); } _switchResult = _string; break; case "Bounds": _switchResult = this.getBounds(); break; case "Multiple Of": Double _multipleOf = this._attributeHelper.getMultipleOf(this.obj); String _string_1 = null; if (_multipleOf!=null) { _string_1=_multipleOf.toString(); } _switchResult = _string_1; break; case "Length": _switchResult = this.getLengthBounds(); break; case "Pattern": String _pattern = this._attributeHelper.getPattern(this.obj); String _htmlEscape = null; if (_pattern!=null) { _htmlEscape=this._htmlHelper.htmlEscape(_pattern); } _switchResult = _htmlEscape; break; case "Allowed Values": _switchResult = this.getEnumList(); break; case "Unique Values": Boolean _uniqueItems = this._attributeHelper.getUniqueItems(this.obj); String _string_2 = null; if (_uniqueItems!=null) { _string_2=_uniqueItems.toString(); } _switchResult = _string_2; break; case "Example": String _example = this._attributeHelper.getExample(this.obj); String _string_3 = null; if (_example!=null) { _string_3=_example.toString(); } _switchResult = _string_3; break; default: throw new IllegalArgumentException(("Internal error - unexpected detail label: " + detailName)); } } else { throw new IllegalArgumentException(("Internal error - unexpected detail label: " + detailName)); } final String value = _switchResult; CharSequence _xifexpression = null; if ((value != null)) { StringConcatenation _builder = new StringConcatenation(); _builder.append(""); _builder.append(detailName); _builder.append(""); _builder.append(value); _builder.append(""); _xifexpression = _builder; } _xblockexpression = _xifexpression; } return _xblockexpression; } private String getBounds() { String _xblockexpression = null; { String _xifexpression = null; Boolean _exclusiveMinimum = this._attributeHelper.getExclusiveMinimum(this.obj); boolean _not = (!(_exclusiveMinimum).booleanValue()); if (_not) { _xifexpression = "="; } final String minEq = _xifexpression; String _xifexpression_1 = null; Boolean _exclusiveMaximum = this._attributeHelper.getExclusiveMaximum(this.obj); boolean _not_1 = (!(_exclusiveMaximum).booleanValue()); if (_not_1) { _xifexpression_1 = "="; } final String maxEq = _xifexpression_1; String _xifexpression_2 = null; String _minimum = this._attributeHelper.getMinimum(this.obj); boolean _tripleNotEquals = (_minimum != null); if (_tripleNotEquals) { String _xifexpression_3 = null; String _maximum = this._attributeHelper.getMaximum(this.obj); boolean _tripleNotEquals_1 = (_maximum != null); if (_tripleNotEquals_1) { StringConcatenation _builder = new StringConcatenation(); String _minimum_1 = this._attributeHelper.getMinimum(this.obj); _builder.append(_minimum_1); _builder.append(" <"); _builder.append(minEq); _builder.append(" "); String _name = this._attributeHelper.getName(this.obj); _builder.append(_name); _builder.append(" <"); _builder.append(maxEq); _builder.append(" "); String _maximum_1 = this._attributeHelper.getMaximum(this.obj); _builder.append(_maximum_1); _xifexpression_3 = _builder.toString(); } _xifexpression_2 = _xifexpression_3; } else { String _xifexpression_4 = null; String _minimum_2 = this._attributeHelper.getMinimum(this.obj); boolean _tripleNotEquals_2 = (_minimum_2 != null); if (_tripleNotEquals_2) { StringConcatenation _builder_1 = new StringConcatenation(); String _name_1 = this._attributeHelper.getName(this.obj); _builder_1.append(_name_1); _builder_1.append(" >"); _builder_1.append(minEq); _builder_1.append(" "); String _minimum_3 = this._attributeHelper.getMinimum(this.obj); _builder_1.append(_minimum_3); _xifexpression_4 = _builder_1.toString(); } else { String _xifexpression_5 = null; String _maximum_2 = this._attributeHelper.getMaximum(this.obj); boolean _tripleNotEquals_3 = (_maximum_2 != null); if (_tripleNotEquals_3) { StringConcatenation _builder_2 = new StringConcatenation(); String _name_2 = this._attributeHelper.getName(this.obj); _builder_2.append(_name_2); _builder_2.append(" <"); _builder_2.append(maxEq); _builder_2.append(" "); String _maximum_3 = this._attributeHelper.getMaximum(this.obj); _builder_2.append(_maximum_3); _xifexpression_5 = _builder_2.toString(); } _xifexpression_4 = _xifexpression_5; } _xifexpression_2 = _xifexpression_4; } final String bounds = _xifexpression_2; String _htmlEscape = null; if (bounds!=null) { _htmlEscape=this._htmlHelper.htmlEscape(bounds); } _xblockexpression = _htmlEscape; } return _xblockexpression; } private String getLengthBounds() { String _xifexpression = null; if ((((this._attributeHelper.getMinLength(this.obj)).intValue() > 0) && ((this._attributeHelper.getMaxLength(this.obj)).intValue() < Integer.MAX_VALUE))) { StringConcatenation _builder = new StringConcatenation(); Integer _minLength = this._attributeHelper.getMinLength(this.obj); _builder.append(_minLength); _builder.append(" <= length <= "); Integer _maxLength = this._attributeHelper.getMaxLength(this.obj); _builder.append(_maxLength); _xifexpression = _builder.toString(); } else { String _xifexpression_1 = null; Integer _minLength_1 = this._attributeHelper.getMinLength(this.obj); boolean _greaterThan = ((_minLength_1).intValue() > 0); if (_greaterThan) { StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("length >= "); Integer _minLength_2 = this._attributeHelper.getMinLength(this.obj); _builder_1.append(_minLength_2); _xifexpression_1 = _builder_1.toString(); } else { String _xifexpression_2 = null; Integer _maxLength_1 = this._attributeHelper.getMaxLength(this.obj); boolean _lessThan = ((_maxLength_1).intValue() < Integer.MAX_VALUE); if (_lessThan) { StringConcatenation _builder_2 = new StringConcatenation(); _builder_2.append("length <= "); Integer _maxLength_2 = this._attributeHelper.getMaxLength(this.obj); _builder_2.append(_maxLength_2); _xifexpression_2 = _builder_2.toString(); } _xifexpression_1 = _xifexpression_2; } _xifexpression = _xifexpression_1; } return _xifexpression; } private String getEnumList() { List _enums = this._attributeHelper.getEnums(this.obj); List _map = null; if (_enums!=null) { final Function1 _function = (Object it) -> { String _string = null; if (it!=null) { _string=it.toString(); } String _htmlEscape = null; if (_string!=null) { _htmlEscape=this._htmlHelper.htmlEscape(_string); } return _htmlEscape; }; _map=ListExtensions.map(_enums, _function); } String _join = null; if (_map!=null) { _join=IterableExtensions.join(_map, "
"); } return _join; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy