001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_control-common_metaschema.xml
002// Do not edit - changes will be lost when regenerated.
003package dev.metaschema.oscal.lib.model;
004
005import dev.metaschema.core.datatype.adapter.StringAdapter;
006import dev.metaschema.core.datatype.markup.MarkupMultiline;
007import dev.metaschema.core.datatype.markup.MarkupMultilineAdapter;
008import dev.metaschema.core.model.IBoundObject;
009import dev.metaschema.core.model.IMetaschemaData;
010import dev.metaschema.core.model.JsonGroupAsBehavior;
011import dev.metaschema.core.util.ObjectUtils;
012import dev.metaschema.databind.model.annotations.BoundAssembly;
013import dev.metaschema.databind.model.annotations.BoundField;
014import dev.metaschema.databind.model.annotations.GroupAs;
015import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
016import edu.umd.cs.findbugs.annotations.NonNull;
017import edu.umd.cs.findbugs.annotations.Nullable;
018import java.util.LinkedList;
019import java.util.List;
020import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
021import org.apache.commons.lang3.builder.ToStringStyle;
022
023/**
024 * A formal or informal expression of a constraint or test.
025 */
026@MetaschemaAssembly(
027    formalName = "Constraint",
028    description = "A formal or informal expression of a constraint or test.",
029    name = "parameter-constraint",
030    moduleClass = OscalControlCommonModule.class
031)
032public class ParameterConstraint implements IBoundObject {
033  private final IMetaschemaData __metaschemaData;
034
035  /**
036   * A textual summary of the constraint to be applied.
037   */
038  @BoundField(
039      formalName = "Constraint Description",
040      description = "A textual summary of the constraint to be applied.",
041      useName = "description",
042      typeAdapter = MarkupMultilineAdapter.class
043  )
044  private MarkupMultiline _description;
045
046  /**
047   * A test expression which is expected to be evaluated by a tool.
048   */
049  @BoundAssembly(
050      formalName = "Constraint Test",
051      description = "A test expression which is expected to be evaluated by a tool.",
052      useName = "test",
053      maxOccurs = -1,
054      groupAs = @GroupAs(name = "tests", inJson = JsonGroupAsBehavior.LIST)
055  )
056  private List<Test> _tests;
057
058  /**
059   * Constructs a new {@code dev.metaschema.oscal.lib.model.ParameterConstraint} instance with no metadata.
060   */
061  public ParameterConstraint() {
062    this(null);
063  }
064
065  /**
066   * Constructs a new {@code dev.metaschema.oscal.lib.model.ParameterConstraint} instance with the specified metadata.
067   *
068   * @param data
069   *           the metaschema data, or {@code null} if none
070   */
071  public ParameterConstraint(IMetaschemaData data) {
072    this.__metaschemaData = data;
073  }
074
075  @Override
076  public IMetaschemaData getMetaschemaData() {
077    return __metaschemaData;
078  }
079
080  /**
081   * Get the "{@literal Constraint Description}".
082   *
083   * <p>
084   * A textual summary of the constraint to be applied.
085   *
086   * @return the description value, or {@code null} if not set
087   */
088  @Nullable
089  public MarkupMultiline getDescription() {
090    return _description;
091  }
092
093  /**
094   * Set the "{@literal Constraint Description}".
095   *
096   * <p>
097   * A textual summary of the constraint to be applied.
098   *
099   * @param value
100   *           the description value to set, or {@code null} to clear
101   */
102  public void setDescription(@Nullable MarkupMultiline value) {
103    _description = value;
104  }
105
106  /**
107   * Get the "{@literal Constraint Test}".
108   *
109   * <p>
110   * A test expression which is expected to be evaluated by a tool.
111   *
112   * @return the test value
113   */
114  @NonNull
115  public List<Test> getTests() {
116    if (_tests == null) {
117      _tests = new LinkedList<>();
118    }
119    return ObjectUtils.notNull(_tests);
120  }
121
122  /**
123   * Set the "{@literal Constraint Test}".
124   *
125   * <p>
126   * A test expression which is expected to be evaluated by a tool.
127   *
128   * @param value
129   *           the test value to set
130   */
131  public void setTests(@NonNull List<Test> value) {
132    _tests = value;
133  }
134
135  /**
136   * Add a new {@link Test} item to the underlying collection.
137   * @param item the item to add
138   * @return {@code true}
139   */
140  public boolean addTest(Test item) {
141    Test value = ObjectUtils.requireNonNull(item,"item cannot be null");
142    if (_tests == null) {
143      _tests = new LinkedList<>();
144    }
145    return _tests.add(value);
146  }
147
148  /**
149   * Remove the first matching {@link Test} item from the underlying collection.
150   * @param item the item to remove
151   * @return {@code true} if the item was removed or {@code false} otherwise
152   */
153  public boolean removeTest(Test item) {
154    Test value = ObjectUtils.requireNonNull(item,"item cannot be null");
155    return _tests != null && _tests.remove(value);
156  }
157
158  @Override
159  public String toString() {
160    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
161  }
162
163  /**
164   * A test expression which is expected to be evaluated by a tool.
165   */
166  @MetaschemaAssembly(
167      formalName = "Constraint Test",
168      description = "A test expression which is expected to be evaluated by a tool.",
169      name = "test",
170      moduleClass = OscalControlCommonModule.class
171  )
172  public static class Test implements IBoundObject {
173    private final IMetaschemaData __metaschemaData;
174
175    /**
176     * A formal (executable) expression of a constraint.
177     */
178    @BoundField(
179        formalName = "Constraint test",
180        description = "A formal (executable) expression of a constraint.",
181        useName = "expression",
182        minOccurs = 1,
183        typeAdapter = StringAdapter.class
184    )
185    private String _expression;
186
187    /**
188     * Additional commentary about the containing object.
189     */
190    @BoundField(
191        formalName = "Remarks",
192        description = "Additional commentary about the containing object.",
193        useName = "remarks",
194        typeAdapter = MarkupMultilineAdapter.class
195    )
196    private MarkupMultiline _remarks;
197
198    /**
199     * Constructs a new {@code dev.metaschema.oscal.lib.model.ParameterConstraint.Test} instance with no metadata.
200     */
201    public Test() {
202      this(null);
203    }
204
205    /**
206     * Constructs a new {@code dev.metaschema.oscal.lib.model.ParameterConstraint.Test} instance with the specified metadata.
207     *
208     * @param data
209     *           the metaschema data, or {@code null} if none
210     */
211    public Test(IMetaschemaData data) {
212      this.__metaschemaData = data;
213    }
214
215    @Override
216    public IMetaschemaData getMetaschemaData() {
217      return __metaschemaData;
218    }
219
220    /**
221     * Get the "{@literal Constraint test}".
222     *
223     * <p>
224     * A formal (executable) expression of a constraint.
225     *
226     * @return the expression value
227     */
228    @NonNull
229    public String getExpression() {
230      return _expression;
231    }
232
233    /**
234     * Set the "{@literal Constraint test}".
235     *
236     * <p>
237     * A formal (executable) expression of a constraint.
238     *
239     * @param value
240     *           the expression value to set
241     */
242    public void setExpression(@NonNull String value) {
243      _expression = value;
244    }
245
246    /**
247     * Get the "{@literal Remarks}".
248     *
249     * <p>
250     * Additional commentary about the containing object.
251     *
252     * @return the remarks value, or {@code null} if not set
253     */
254    @Nullable
255    public MarkupMultiline getRemarks() {
256      return _remarks;
257    }
258
259    /**
260     * Set the "{@literal Remarks}".
261     *
262     * <p>
263     * Additional commentary about the containing object.
264     *
265     * @param value
266     *           the remarks value to set, or {@code null} to clear
267     */
268    public void setRemarks(@Nullable MarkupMultiline value) {
269      _remarks = value;
270    }
271
272    @Override
273    public String toString() {
274      return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
275    }
276  }
277}