001package com.example.metaschema;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter;
004import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine;
006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter;
007import gov.nist.secauto.metaschema.core.model.IBoundObject;
008import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
009import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
010import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
011import gov.nist.secauto.metaschema.core.util.ObjectUtils;
012import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
013import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
014import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
015import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
016import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
017import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
018import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
019import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
020import java.lang.Override;
021import java.lang.String;
022import java.util.LinkedList;
023import java.util.List;
024import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
025import org.apache.commons.lang3.builder.ToStringStyle;
026
027@MetaschemaAssembly(
028    formalName = "Allowed Values Constraint",
029    name = "targeted-allowed-values-constraint",
030    moduleClass = MetaschemaModelModule.class
031)
032public class TargetedAllowedValuesConstraint implements IBoundObject {
033  private final IMetaschemaData __metaschemaData;
034
035  @BoundFlag(
036      formalName = "Constraint Identifier",
037      name = "id",
038      typeAdapter = TokenAdapter.class
039  )
040  private String _id;
041
042  @BoundFlag(
043      formalName = "Constraint Severity Level",
044      name = "level",
045      defaultValue = "ERROR",
046      typeAdapter = TokenAdapter.class,
047      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.")}))
048  )
049  private String _level;
050
051  @BoundFlag(
052      formalName = "Allow Non-Enumerated Values?",
053      name = "allow-other",
054      defaultValue = "no",
055      typeAdapter = TokenAdapter.class,
056      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "no", description = "Other value are not allowed."), @AllowedValue(value = "yes", description = "Other values are allowed.")}))
057  )
058  private String _allowOther;
059
060  /**
061   * "Determines if the given enumerated values may be extended by other allowed value constraints."
062   */
063  @BoundFlag(
064      formalName = "Allow Extension?",
065      description = "Determines if the given enumerated values may be extended by other allowed value constraints.",
066      name = "extensible",
067      defaultValue = "external",
068      typeAdapter = TokenAdapter.class,
069      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "model", description = "Can be extended by constraints within the same module."), @AllowedValue(value = "external", description = "Can be extended by external constraints."), @AllowedValue(value = "none", description = "Cannot be extended.")}))
070  )
071  private String _extensible;
072
073  @BoundFlag(
074      formalName = "Constraint Target Metapath Expression",
075      name = "target",
076      required = true,
077      typeAdapter = StringAdapter.class
078  )
079  private String _target;
080
081  @BoundField(
082      formalName = "Formal Name",
083      description = "A formal name for the data construct, to be presented in documentation.",
084      useName = "formal-name"
085  )
086  private String _formalName;
087
088  @BoundField(
089      formalName = "Description",
090      description = "A short description of the data construct's purpose, describing the constructs semantics.",
091      useName = "description",
092      typeAdapter = MarkupLineAdapter.class
093  )
094  private MarkupLine _description;
095
096  @BoundAssembly(
097      formalName = "Property",
098      useName = "prop",
099      maxOccurs = -1,
100      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
101  )
102  private List<Property> _props;
103
104  @BoundField(
105      formalName = "Allowed Value Enumeration",
106      useName = "enum",
107      minOccurs = 1,
108      maxOccurs = -1,
109      groupAs = @GroupAs(name = "enums", inJson = JsonGroupAsBehavior.LIST)
110  )
111  private List<ConstraintValueEnum> _enums;
112
113  @BoundField(
114      formalName = "Remarks",
115      description = "Any explanatory or helpful information to be provided about the remarks parent.",
116      useName = "remarks"
117  )
118  private Remarks _remarks;
119
120  public TargetedAllowedValuesConstraint() {
121    this(null);
122  }
123
124  public TargetedAllowedValuesConstraint(IMetaschemaData data) {
125    this.__metaschemaData = data;
126  }
127
128  @Override
129  public IMetaschemaData getMetaschemaData() {
130    return __metaschemaData;
131  }
132
133  public String getId() {
134    return _id;
135  }
136
137  public void setId(String value) {
138    _id = value;
139  }
140
141  public String getLevel() {
142    return _level;
143  }
144
145  public void setLevel(String value) {
146    _level = value;
147  }
148
149  public String getAllowOther() {
150    return _allowOther;
151  }
152
153  public void setAllowOther(String value) {
154    _allowOther = value;
155  }
156
157  public String getExtensible() {
158    return _extensible;
159  }
160
161  public void setExtensible(String value) {
162    _extensible = value;
163  }
164
165  public String getTarget() {
166    return _target;
167  }
168
169  public void setTarget(String value) {
170    _target = value;
171  }
172
173  public String getFormalName() {
174    return _formalName;
175  }
176
177  public void setFormalName(String value) {
178    _formalName = value;
179  }
180
181  public MarkupLine getDescription() {
182    return _description;
183  }
184
185  public void setDescription(MarkupLine value) {
186    _description = value;
187  }
188
189  public List<Property> getProps() {
190    return _props;
191  }
192
193  public void setProps(List<Property> value) {
194    _props = value;
195  }
196
197  /**
198   * Add a new {@link Property} item to the underlying collection.
199   * @param item the item to add
200   * @return {@code true}
201   */
202  public boolean addProp(Property item) {
203    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
204    if (_props == null) {
205      _props = new LinkedList<>();
206    }
207    return _props.add(value);
208  }
209
210  /**
211   * Remove the first matching {@link Property} item from the underlying collection.
212   * @param item the item to remove
213   * @return {@code true} if the item was removed or {@code false} otherwise
214   */
215  public boolean removeProp(Property item) {
216    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
217    return _props != null && _props.remove(value);
218  }
219
220  public List<ConstraintValueEnum> getEnums() {
221    return _enums;
222  }
223
224  public void setEnums(List<ConstraintValueEnum> value) {
225    _enums = value;
226  }
227
228  /**
229   * Add a new {@link ConstraintValueEnum} item to the underlying collection.
230   * @param item the item to add
231   * @return {@code true}
232   */
233  public boolean addEnum(ConstraintValueEnum item) {
234    ConstraintValueEnum value = ObjectUtils.requireNonNull(item,"item cannot be null");
235    if (_enums == null) {
236      _enums = new LinkedList<>();
237    }
238    return _enums.add(value);
239  }
240
241  /**
242   * Remove the first matching {@link ConstraintValueEnum} item from the underlying collection.
243   * @param item the item to remove
244   * @return {@code true} if the item was removed or {@code false} otherwise
245   */
246  public boolean removeEnum(ConstraintValueEnum item) {
247    ConstraintValueEnum value = ObjectUtils.requireNonNull(item,"item cannot be null");
248    return _enums != null && _enums.remove(value);
249  }
250
251  public Remarks getRemarks() {
252    return _remarks;
253  }
254
255  public void setRemarks(Remarks value) {
256    _remarks = value;
257  }
258
259  @Override
260  public String toString() {
261    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
262  }
263}