001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_assessment-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.TokenAdapter;
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.model.constraint.IConstraint;
012import dev.metaschema.core.util.ObjectUtils;
013import dev.metaschema.databind.model.annotations.AllowedValue;
014import dev.metaschema.databind.model.annotations.AllowedValues;
015import dev.metaschema.databind.model.annotations.AssemblyConstraints;
016import dev.metaschema.databind.model.annotations.BoundAssembly;
017import dev.metaschema.databind.model.annotations.BoundField;
018import dev.metaschema.databind.model.annotations.BoundFlag;
019import dev.metaschema.databind.model.annotations.GroupAs;
020import dev.metaschema.databind.model.annotations.HasCardinality;
021import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
022import dev.metaschema.databind.model.annotations.ValueConstraints;
023import edu.umd.cs.findbugs.annotations.NonNull;
024import edu.umd.cs.findbugs.annotations.Nullable;
025import java.util.LinkedList;
026import java.util.List;
027import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
028import org.apache.commons.lang3.builder.ToStringStyle;
029
030/**
031 * A local definition of a control objective for this assessment. Uses catalog syntax for control objective and assessment actions.
032 */
033@MetaschemaAssembly(
034    formalName = "Assessment-Specific Control Objective",
035    description = "A local definition of a control objective for this assessment. Uses catalog syntax for control objective and assessment actions.",
036    name = "local-objective",
037    moduleClass = OscalAssessmentCommonModule.class,
038    valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(id = "oscal-assessment-objective-types", level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@name", values = {@AllowedValue(value = "objective", description = "\\*\\*(deprecated)\\*\\* Use 'assessment-objective' instead.", deprecatedVersion = "1.0.1"), @AllowedValue(value = "assessment", description = "\\*\\*(deprecated)\\*\\* Use 'assessment-method' instead.", deprecatedVersion = "1.0.1"), @AllowedValue(value = "assessment-objective", description = "The part defines an assessment objective."), @AllowedValue(value = "assessment-method", description = "The part defines an assessment method.")})),
039    modelConstraints = @AssemblyConstraints(cardinality = {@HasCardinality(id = "oscal-assessment-objective-cardinality", level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name=('objective','assessment-objective')]", maxOccurs = 1), @HasCardinality(id = "oscal-assessment-method-cardinality", level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name=('assessment','assessment-method')]/prop[has-oscal-namespace(('http://csrc.nist.gov/ns/oscal','http://csrc.nist.gov/ns/rmf')) and @name='method']", minOccurs = 1, maxOccurs = 1), @HasCardinality(id = "oscal-assessment-objects-cardinality", level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name=('assessment','assessment-method')]/part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name=('objects','assessment-objects')]", minOccurs = 1, maxOccurs = 1), @HasCardinality(id = "oscal-assessment-method-id-cardinality", level = IConstraint.Level.ERROR, target = "part[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name=('objective','assessment-objective')]/prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name='method-id']", minOccurs = 1)})
040)
041public class LocalObjective implements IBoundObject {
042  private final IMetaschemaData __metaschemaData;
043
044  /**
045   * A reference to a control with a corresponding <code>id</code> value. When referencing an externally defined <code>control</code>, the <code>Control Identifier Reference</code> must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).
046   */
047  @BoundFlag(
048      formalName = "Control Identifier Reference",
049      description = "A reference to a control with a corresponding `id` value. When referencing an externally defined `control`, the `Control Identifier Reference` must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).",
050      name = "control-id",
051      required = true,
052      typeAdapter = TokenAdapter.class,
053      remarks = "The specified `control-id` must be a valid value within the baseline identified by the target system's SSP via the `import-profile` statement."
054  )
055  private String _controlId;
056
057  /**
058   * A human-readable description of this control objective.
059   */
060  @BoundField(
061      formalName = "Objective Description",
062      description = "A human-readable description of this control objective.",
063      useName = "description",
064      typeAdapter = MarkupMultilineAdapter.class
065  )
066  private MarkupMultiline _description;
067
068  /**
069   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
070   */
071  @BoundAssembly(
072      formalName = "Property",
073      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
074      useName = "prop",
075      maxOccurs = -1,
076      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
077  )
078  private List<Property> _props;
079
080  /**
081   * A reference to a local or remote resource, that has a specific relation to the containing object.
082   */
083  @BoundAssembly(
084      formalName = "Link",
085      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
086      useName = "link",
087      maxOccurs = -1,
088      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
089  )
090  private List<Link> _links;
091
092  /**
093   * An annotated, markup-based textual element of a control's or catalog group's definition, or a child of another part.
094   */
095  @BoundAssembly(
096      formalName = "Part",
097      description = "An annotated, markup-based textual element of a control's or catalog group's definition, or a child of another part.",
098      useName = "part",
099      minOccurs = 1,
100      maxOccurs = -1,
101      groupAs = @GroupAs(name = "parts", inJson = JsonGroupAsBehavior.LIST)
102  )
103  private List<ControlPart> _parts;
104
105  /**
106   * Additional commentary about the containing object.
107   */
108  @BoundField(
109      formalName = "Remarks",
110      description = "Additional commentary about the containing object.",
111      useName = "remarks",
112      typeAdapter = MarkupMultilineAdapter.class
113  )
114  private MarkupMultiline _remarks;
115
116  /**
117   * Constructs a new {@code dev.metaschema.oscal.lib.model.LocalObjective} instance with no metadata.
118   */
119  public LocalObjective() {
120    this(null);
121  }
122
123  /**
124   * Constructs a new {@code dev.metaschema.oscal.lib.model.LocalObjective} instance with the specified metadata.
125   *
126   * @param data
127   *           the metaschema data, or {@code null} if none
128   */
129  public LocalObjective(IMetaschemaData data) {
130    this.__metaschemaData = data;
131  }
132
133  @Override
134  public IMetaschemaData getMetaschemaData() {
135    return __metaschemaData;
136  }
137
138  /**
139   * Get the "{@literal Control Identifier Reference}".
140   *
141   * <p>
142   * A reference to a control with a corresponding <code>id</code> value. When referencing an externally defined <code>control</code>, the <code>Control Identifier Reference</code> must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).
143   *
144   * @return the control-id value
145   */
146  @NonNull
147  public String getControlId() {
148    return _controlId;
149  }
150
151  /**
152   * Set the "{@literal Control Identifier Reference}".
153   *
154   * <p>
155   * A reference to a control with a corresponding <code>id</code> value. When referencing an externally defined <code>control</code>, the <code>Control Identifier Reference</code> must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).
156   *
157   * @param value
158   *           the control-id value to set
159   */
160  public void setControlId(@NonNull String value) {
161    _controlId = value;
162  }
163
164  /**
165   * Get the "{@literal Objective Description}".
166   *
167   * <p>
168   * A human-readable description of this control objective.
169   *
170   * @return the description value, or {@code null} if not set
171   */
172  @Nullable
173  public MarkupMultiline getDescription() {
174    return _description;
175  }
176
177  /**
178   * Set the "{@literal Objective Description}".
179   *
180   * <p>
181   * A human-readable description of this control objective.
182   *
183   * @param value
184   *           the description value to set, or {@code null} to clear
185   */
186  public void setDescription(@Nullable MarkupMultiline value) {
187    _description = value;
188  }
189
190  /**
191   * Get the "{@literal Property}".
192   *
193   * <p>
194   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
195   *
196   * @return the prop value
197   */
198  @NonNull
199  public List<Property> getProps() {
200    if (_props == null) {
201      _props = new LinkedList<>();
202    }
203    return ObjectUtils.notNull(_props);
204  }
205
206  /**
207   * Set the "{@literal Property}".
208   *
209   * <p>
210   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
211   *
212   * @param value
213   *           the prop value to set
214   */
215  public void setProps(@NonNull List<Property> value) {
216    _props = value;
217  }
218
219  /**
220   * Add a new {@link Property} item to the underlying collection.
221   * @param item the item to add
222   * @return {@code true}
223   */
224  public boolean addProp(Property item) {
225    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
226    if (_props == null) {
227      _props = new LinkedList<>();
228    }
229    return _props.add(value);
230  }
231
232  /**
233   * Remove the first matching {@link Property} item from the underlying collection.
234   * @param item the item to remove
235   * @return {@code true} if the item was removed or {@code false} otherwise
236   */
237  public boolean removeProp(Property item) {
238    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
239    return _props != null && _props.remove(value);
240  }
241
242  /**
243   * Get the "{@literal Link}".
244   *
245   * <p>
246   * A reference to a local or remote resource, that has a specific relation to the containing object.
247   *
248   * @return the link value
249   */
250  @NonNull
251  public List<Link> getLinks() {
252    if (_links == null) {
253      _links = new LinkedList<>();
254    }
255    return ObjectUtils.notNull(_links);
256  }
257
258  /**
259   * Set the "{@literal Link}".
260   *
261   * <p>
262   * A reference to a local or remote resource, that has a specific relation to the containing object.
263   *
264   * @param value
265   *           the link value to set
266   */
267  public void setLinks(@NonNull List<Link> value) {
268    _links = value;
269  }
270
271  /**
272   * Add a new {@link Link} item to the underlying collection.
273   * @param item the item to add
274   * @return {@code true}
275   */
276  public boolean addLink(Link item) {
277    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
278    if (_links == null) {
279      _links = new LinkedList<>();
280    }
281    return _links.add(value);
282  }
283
284  /**
285   * Remove the first matching {@link Link} item from the underlying collection.
286   * @param item the item to remove
287   * @return {@code true} if the item was removed or {@code false} otherwise
288   */
289  public boolean removeLink(Link item) {
290    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
291    return _links != null && _links.remove(value);
292  }
293
294  /**
295   * Get the "{@literal Part}".
296   *
297   * <p>
298   * An annotated, markup-based textual element of a control's or catalog group's definition, or a child of another part.
299   *
300   * @return the part value
301   */
302  @NonNull
303  public List<ControlPart> getParts() {
304    if (_parts == null) {
305      _parts = new LinkedList<>();
306    }
307    return ObjectUtils.notNull(_parts);
308  }
309
310  /**
311   * Set the "{@literal Part}".
312   *
313   * <p>
314   * An annotated, markup-based textual element of a control's or catalog group's definition, or a child of another part.
315   *
316   * @param value
317   *           the part value to set
318   */
319  public void setParts(@NonNull List<ControlPart> value) {
320    _parts = value;
321  }
322
323  /**
324   * Add a new {@link ControlPart} item to the underlying collection.
325   * @param item the item to add
326   * @return {@code true}
327   */
328  public boolean addPart(ControlPart item) {
329    ControlPart value = ObjectUtils.requireNonNull(item,"item cannot be null");
330    if (_parts == null) {
331      _parts = new LinkedList<>();
332    }
333    return _parts.add(value);
334  }
335
336  /**
337   * Remove the first matching {@link ControlPart} item from the underlying collection.
338   * @param item the item to remove
339   * @return {@code true} if the item was removed or {@code false} otherwise
340   */
341  public boolean removePart(ControlPart item) {
342    ControlPart value = ObjectUtils.requireNonNull(item,"item cannot be null");
343    return _parts != null && _parts.remove(value);
344  }
345
346  /**
347   * Get the "{@literal Remarks}".
348   *
349   * <p>
350   * Additional commentary about the containing object.
351   *
352   * @return the remarks value, or {@code null} if not set
353   */
354  @Nullable
355  public MarkupMultiline getRemarks() {
356    return _remarks;
357  }
358
359  /**
360   * Set the "{@literal Remarks}".
361   *
362   * <p>
363   * Additional commentary about the containing object.
364   *
365   * @param value
366   *           the remarks value to set, or {@code null} to clear
367   */
368  public void setRemarks(@Nullable MarkupMultiline value) {
369    _remarks = value;
370  }
371
372  @Override
373  public String toString() {
374    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
375  }
376}