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 = "Expect Condition Constraint",
029    name = "targeted-expect-constraint",
030    moduleClass = MetaschemaModelModule.class
031)
032public class TargetedExpectConstraint 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 = "Expect Test Condition",
053      name = "test",
054      required = true,
055      typeAdapter = StringAdapter.class
056  )
057  private String _test;
058
059  @BoundFlag(
060      formalName = "Constraint Target Metapath Expression",
061      name = "target",
062      required = true,
063      typeAdapter = StringAdapter.class
064  )
065  private String _target;
066
067  @BoundField(
068      formalName = "Formal Name",
069      description = "A formal name for the data construct, to be presented in documentation.",
070      useName = "formal-name"
071  )
072  private String _formalName;
073
074  @BoundField(
075      formalName = "Description",
076      description = "A short description of the data construct's purpose, describing the constructs semantics.",
077      useName = "description",
078      typeAdapter = MarkupLineAdapter.class
079  )
080  private MarkupLine _description;
081
082  @BoundAssembly(
083      formalName = "Property",
084      useName = "prop",
085      maxOccurs = -1,
086      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
087  )
088  private List<Property> _props;
089
090  @BoundField(
091      formalName = "Constraint Condition Violation Message",
092      useName = "message"
093  )
094  private String _message;
095
096  @BoundField(
097      formalName = "Remarks",
098      description = "Any explanatory or helpful information to be provided about the remarks parent.",
099      useName = "remarks"
100  )
101  private Remarks _remarks;
102
103  public TargetedExpectConstraint() {
104    this(null);
105  }
106
107  public TargetedExpectConstraint(IMetaschemaData data) {
108    this.__metaschemaData = data;
109  }
110
111  @Override
112  public IMetaschemaData getMetaschemaData() {
113    return __metaschemaData;
114  }
115
116  public String getId() {
117    return _id;
118  }
119
120  public void setId(String value) {
121    _id = value;
122  }
123
124  public String getLevel() {
125    return _level;
126  }
127
128  public void setLevel(String value) {
129    _level = value;
130  }
131
132  public String getTest() {
133    return _test;
134  }
135
136  public void setTest(String value) {
137    _test = value;
138  }
139
140  public String getTarget() {
141    return _target;
142  }
143
144  public void setTarget(String value) {
145    _target = value;
146  }
147
148  public String getFormalName() {
149    return _formalName;
150  }
151
152  public void setFormalName(String value) {
153    _formalName = value;
154  }
155
156  public MarkupLine getDescription() {
157    return _description;
158  }
159
160  public void setDescription(MarkupLine value) {
161    _description = value;
162  }
163
164  public List<Property> getProps() {
165    return _props;
166  }
167
168  public void setProps(List<Property> value) {
169    _props = value;
170  }
171
172  /**
173   * Add a new {@link Property} item to the underlying collection.
174   * @param item the item to add
175   * @return {@code true}
176   */
177  public boolean addProp(Property item) {
178    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
179    if (_props == null) {
180      _props = new LinkedList<>();
181    }
182    return _props.add(value);
183  }
184
185  /**
186   * Remove the first matching {@link Property} item from the underlying collection.
187   * @param item the item to remove
188   * @return {@code true} if the item was removed or {@code false} otherwise
189   */
190  public boolean removeProp(Property item) {
191    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
192    return _props != null && _props.remove(value);
193  }
194
195  public String getMessage() {
196    return _message;
197  }
198
199  public void setMessage(String value) {
200    _message = value;
201  }
202
203  public Remarks getRemarks() {
204    return _remarks;
205  }
206
207  public void setRemarks(Remarks value) {
208    _remarks = value;
209  }
210
211  @Override
212  public String toString() {
213    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
214  }
215}