001package com.example.metaschema;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.NonNegativeIntegerAdapter;
004import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter;
005import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine;
007import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter;
008import gov.nist.secauto.metaschema.core.model.IBoundObject;
009import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
010import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
011import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
012import gov.nist.secauto.metaschema.core.util.ObjectUtils;
013import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
014import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
015import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
016import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
017import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
018import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
019import gov.nist.secauto.metaschema.databind.model.annotations.Matches;
020import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
021import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
022import java.lang.Override;
023import java.lang.String;
024import java.math.BigInteger;
025import java.util.LinkedList;
026import java.util.List;
027import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
028import org.apache.commons.lang3.builder.ToStringStyle;
029
030@MetaschemaAssembly(
031    formalName = "Targeted Cardinality Constraint",
032    name = "targeted-has-cardinality-constraint",
033    moduleClass = MetaschemaModelModule.class
034)
035public class TargetedHasCardinalityConstraint implements IBoundObject {
036  private final IMetaschemaData __metaschemaData;
037
038  @BoundFlag(
039      formalName = "Constraint Identifier",
040      name = "id",
041      typeAdapter = TokenAdapter.class
042  )
043  private String _id;
044
045  @BoundFlag(
046      formalName = "Constraint Severity Level",
047      name = "level",
048      defaultValue = "ERROR",
049      typeAdapter = TokenAdapter.class,
050      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "CRITICAL", description = "A violation of the constraint represents a serious fault in the content that will prevent typical use of the content."), @AllowedValue(value = "ERROR", description = "A violation of the constraint represents a fault in the content. This may include issues around compatibility, integrity, consistency, etc."), @AllowedValue(value = "WARNING", description = "A violation of the constraint represents a potential issue with the content."), @AllowedValue(value = "INFORMATIONAL", description = "A violation of the constraint represents a point of interest."), @AllowedValue(value = "DEBUG", description = "A violation of the constraint represents a fault in the content that may warrant review by a developer when performing model or tool development.")}))
051  )
052  private String _level;
053
054  @BoundFlag(
055      formalName = "Minimum Occurrence",
056      name = "min-occurs",
057      typeAdapter = NonNegativeIntegerAdapter.class
058  )
059  private BigInteger _minOccurs;
060
061  @BoundFlag(
062      formalName = "Maximum Occurrence",
063      name = "max-occurs",
064      typeAdapter = StringAdapter.class,
065      valueConstraints = @ValueConstraints(matches = @Matches(level = IConstraint.Level.ERROR, pattern = "^[1-9][0-9]*|unbounded$"))
066  )
067  private String _maxOccurs;
068
069  @BoundFlag(
070      formalName = "Constraint Target Metapath Expression",
071      name = "target",
072      required = true,
073      typeAdapter = StringAdapter.class
074  )
075  private String _target;
076
077  @BoundField(
078      formalName = "Formal Name",
079      description = "A formal name for the data construct, to be presented in documentation.",
080      useName = "formal-name"
081  )
082  private String _formalName;
083
084  @BoundField(
085      formalName = "Description",
086      description = "A short description of the data construct's purpose, describing the constructs semantics.",
087      useName = "description",
088      typeAdapter = MarkupLineAdapter.class
089  )
090  private MarkupLine _description;
091
092  @BoundAssembly(
093      formalName = "Property",
094      useName = "prop",
095      maxOccurs = -1,
096      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
097  )
098  private List<Property> _props;
099
100  @BoundField(
101      formalName = "Constraint Condition Violation Message",
102      useName = "message"
103  )
104  private String _message;
105
106  @BoundField(
107      formalName = "Remarks",
108      description = "Any explanatory or helpful information to be provided about the remarks parent.",
109      useName = "remarks"
110  )
111  private Remarks _remarks;
112
113  public TargetedHasCardinalityConstraint() {
114    this(null);
115  }
116
117  public TargetedHasCardinalityConstraint(IMetaschemaData data) {
118    this.__metaschemaData = data;
119  }
120
121  @Override
122  public IMetaschemaData getMetaschemaData() {
123    return __metaschemaData;
124  }
125
126  public String getId() {
127    return _id;
128  }
129
130  public void setId(String value) {
131    _id = value;
132  }
133
134  public String getLevel() {
135    return _level;
136  }
137
138  public void setLevel(String value) {
139    _level = value;
140  }
141
142  public BigInteger getMinOccurs() {
143    return _minOccurs;
144  }
145
146  public void setMinOccurs(BigInteger value) {
147    _minOccurs = value;
148  }
149
150  public String getMaxOccurs() {
151    return _maxOccurs;
152  }
153
154  public void setMaxOccurs(String value) {
155    _maxOccurs = value;
156  }
157
158  public String getTarget() {
159    return _target;
160  }
161
162  public void setTarget(String value) {
163    _target = value;
164  }
165
166  public String getFormalName() {
167    return _formalName;
168  }
169
170  public void setFormalName(String value) {
171    _formalName = value;
172  }
173
174  public MarkupLine getDescription() {
175    return _description;
176  }
177
178  public void setDescription(MarkupLine value) {
179    _description = value;
180  }
181
182  public List<Property> getProps() {
183    return _props;
184  }
185
186  public void setProps(List<Property> value) {
187    _props = value;
188  }
189
190  /**
191   * Add a new {@link Property} item to the underlying collection.
192   * @param item the item to add
193   * @return {@code true}
194   */
195  public boolean addProp(Property item) {
196    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
197    if (_props == null) {
198      _props = new LinkedList<>();
199    }
200    return _props.add(value);
201  }
202
203  /**
204   * Remove the first matching {@link Property} item from the underlying collection.
205   * @param item the item to remove
206   * @return {@code true} if the item was removed or {@code false} otherwise
207   */
208  public boolean removeProp(Property item) {
209    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
210    return _props != null && _props.remove(value);
211  }
212
213  public String getMessage() {
214    return _message;
215  }
216
217  public void setMessage(String value) {
218    _message = value;
219  }
220
221  public Remarks getRemarks() {
222    return _remarks;
223  }
224
225  public void setRemarks(Remarks value) {
226    _remarks = value;
227  }
228
229  @Override
230  public String toString() {
231    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
232  }
233}