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.adapter.TokenAdapter;
007import dev.metaschema.core.datatype.markup.MarkupLine;
008import dev.metaschema.core.datatype.markup.MarkupLineAdapter;
009import dev.metaschema.core.datatype.markup.MarkupMultiline;
010import dev.metaschema.core.datatype.markup.MarkupMultilineAdapter;
011import dev.metaschema.core.model.IBoundObject;
012import dev.metaschema.core.model.IMetaschemaData;
013import dev.metaschema.core.model.JsonGroupAsBehavior;
014import dev.metaschema.core.model.constraint.IConstraint;
015import dev.metaschema.core.util.ObjectUtils;
016import dev.metaschema.databind.model.annotations.AllowedValue;
017import dev.metaschema.databind.model.annotations.AllowedValues;
018import dev.metaschema.databind.model.annotations.BoundAssembly;
019import dev.metaschema.databind.model.annotations.BoundChoice;
020import dev.metaschema.databind.model.annotations.BoundField;
021import dev.metaschema.databind.model.annotations.BoundFlag;
022import dev.metaschema.databind.model.annotations.Expect;
023import dev.metaschema.databind.model.annotations.GroupAs;
024import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
025import dev.metaschema.databind.model.annotations.ValueConstraints;
026import dev.metaschema.oscal.lib.model.control.AbstractParameter;
027import edu.umd.cs.findbugs.annotations.NonNull;
028import edu.umd.cs.findbugs.annotations.Nullable;
029import java.util.LinkedList;
030import java.util.List;
031import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
032import org.apache.commons.lang3.builder.ToStringStyle;
033
034/**
035 * Parameters provide a mechanism for the dynamic assignment of value(s) in a control.
036 */
037@MetaschemaAssembly(
038    formalName = "Parameter",
039    description = "Parameters provide a mechanism for the dynamic assignment of value(s) in a control.",
040    name = "parameter",
041    moduleClass = OscalControlCommonModule.class,
042    remarks = "In a catalog, a parameter is typically used as a placeholder for the future assignment of a parameter value, although the OSCAL model allows for the direct assignment of a value if desired by the control author. The `value` may be optionally used to specify one or more values. If no value is provided, then it is expected that the value will be provided at the Profile or Implementation layer.\n"
043            + "\n"
044            + "A parameter can include a variety of metadata options that support the future solicitation of one or more values. A `label` provides a textual placeholder that can be used in a tool to solicit parameter value input, or to display in catalog documentation. The `desc` provides a short description of what the parameter is used for, which can be used in tooling to help a user understand how to use the parameter. A `constraint` can be used to provide criteria for the allowed values. A `guideline` provides a recommendation for the use of a parameter.",
045    valueConstraints = @ValueConstraints(allowedValues = {@AllowedValues(id = "oscal-parameter-prop-name", level = IConstraint.Level.ERROR, target = "prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@name", values = {@AllowedValue(value = "label", description = "A human-readable label for the parent context, which may be rendered in place of the actual identifier for some use cases."), @AllowedValue(value = "sort-id", description = "An alternative identifier, whose value is easily sortable among other such values in the document."), @AllowedValue(value = "alt-identifier", description = "An alternate or aliased identifier for the parent context."), @AllowedValue(value = "alt-label", description = "An alternate to the value provided by the parameter's label. This will typically be qualified by a class.")}), @AllowedValues(id = "oscal-rmf-parameter-prop-name", level = IConstraint.Level.ERROR, target = "prop[has-oscal-namespace('http://csrc.nist.gov/ns/rmf')]/@name", values = @AllowedValue(value = "aggregates", description = "The parent parameter provides an aggregation of two or more other parameters, each described by this property."))}, expect = @Expect(id = "oscal-parameter-depends-on-deprecated", level = IConstraint.Level.ERROR, test = "not(exists(@depends-on))", message = "depends-on is deprecated"))
046)
047public class Parameter extends AbstractParameter implements IBoundObject {
048  private final IMetaschemaData __metaschemaData;
049
050  /**
051   * A unique identifier for the parameter.
052   */
053  @BoundFlag(
054      formalName = "Parameter Identifier",
055      description = "A unique identifier for the parameter.",
056      name = "id",
057      required = true,
058      typeAdapter = TokenAdapter.class
059  )
060  private String _id;
061
062  /**
063   * A textual label that provides a characterization of the type, purpose, use or scope of the parameter.
064   */
065  @BoundFlag(
066      formalName = "Parameter Class",
067      description = "A textual label that provides a characterization of the type, purpose, use or scope of the parameter.",
068      name = "class",
069      typeAdapter = TokenAdapter.class,
070      remarks = "A `class` can be used in validation rules to express extra constraints over named items of a specific `class` value."
071  )
072  private String _clazz;
073
074  /**
075   * <strong>(deprecated)</strong> Another parameter invoking this one. This construct has been deprecated and should not be used.
076   */
077  @BoundFlag(
078      formalName = "Depends on",
079      description = "**(deprecated)** Another parameter invoking this one. This construct has been deprecated and should not be used.",
080      name = "depends-on",
081      typeAdapter = TokenAdapter.class
082  )
083  private String _dependsOn;
084
085  /**
086   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
087   */
088  @BoundAssembly(
089      formalName = "Property",
090      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
091      useName = "prop",
092      maxOccurs = -1,
093      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
094  )
095  private List<Property> _props;
096
097  /**
098   * A reference to a local or remote resource, that has a specific relation to the containing object.
099   */
100  @BoundAssembly(
101      formalName = "Link",
102      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
103      useName = "link",
104      maxOccurs = -1,
105      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
106  )
107  private List<Link> _links;
108
109  /**
110   * A short, placeholder name for the parameter, which can be used as a substitute for a <code>value</code> if no value is assigned.
111   */
112  @BoundField(
113      formalName = "Parameter Label",
114      description = "A short, placeholder name for the parameter, which can be used as a substitute for a `value` if no value is assigned.",
115      useName = "label",
116      remarks = "The label value is intended use when rendering a parameter in generated documentation or a user interface when a parameter is referenced. Note that labels are not required to be distinctive, which means that parameters within the same control may have the same label.",
117      typeAdapter = MarkupLineAdapter.class
118  )
119  private MarkupLine _label;
120
121  /**
122   * Describes the purpose and use of a parameter.
123   */
124  @BoundField(
125      formalName = "Parameter Usage Description",
126      description = "Describes the purpose and use of a parameter.",
127      useName = "usage",
128      typeAdapter = MarkupMultilineAdapter.class
129  )
130  private MarkupMultiline _usage;
131
132  /**
133   * A formal or informal expression of a constraint or test.
134   */
135  @BoundAssembly(
136      formalName = "Constraint",
137      description = "A formal or informal expression of a constraint or test.",
138      useName = "constraint",
139      maxOccurs = -1,
140      groupAs = @GroupAs(name = "constraints", inJson = JsonGroupAsBehavior.LIST)
141  )
142  private List<ParameterConstraint> _constraints;
143
144  /**
145   * A prose statement that provides a recommendation for the use of a parameter.
146   */
147  @BoundAssembly(
148      formalName = "Guideline",
149      description = "A prose statement that provides a recommendation for the use of a parameter.",
150      useName = "guideline",
151      maxOccurs = -1,
152      groupAs = @GroupAs(name = "guidelines", inJson = JsonGroupAsBehavior.LIST)
153  )
154  private List<ParameterGuideline> _guidelines;
155
156  /**
157   * A parameter value or set of values.
158   */
159  @BoundField(
160      formalName = "Parameter Value",
161      description = "A parameter value or set of values.",
162      useName = "value",
163      remarks = "A set of values provided in a catalog can be redefined in OSCAL's `profile` or `system-security-plan` models.",
164      maxOccurs = -1,
165      groupAs = @GroupAs(name = "values", inJson = JsonGroupAsBehavior.LIST),
166      typeAdapter = StringAdapter.class
167  )
168  @BoundChoice(
169      choiceId = "choice-1"
170  )
171  private List<String> _values;
172
173  /**
174   * Presenting a choice among alternatives.
175   */
176  @BoundAssembly(
177      formalName = "Selection",
178      description = "Presenting a choice among alternatives.",
179      useName = "select",
180      remarks = "The OSCAL parameter `value` construct can be used to prescribe a specific parameter value in a catalog or profile. In cases where a prescriptive value is not possible in a catalog or profile, it may be possible to constrain the set of possible values to a few options. Use of `select` in a parameter instead of `value` is a way of defining value options that **may** be set.\n"
181              + "\n"
182              + "A set of allowed parameter values expressed as a set of options which may be selected. These options constrain the permissible values that may be selected for the containing parameter. When the value assignment is made, such as in an OSCAL profile or system security plan, the actual selected value can be examined to determine if it matches one of the permissible choices for the parameter value.\n"
183              + "\n"
184              + "When the value of `how-many` is set to \"one-or-more\", multiple values may be assigned reflecting more than one choice."
185  )
186  @BoundChoice(
187      choiceId = "choice-1"
188  )
189  private ParameterSelection _select;
190
191  /**
192   * Additional commentary about the containing object.
193   */
194  @BoundField(
195      formalName = "Remarks",
196      description = "Additional commentary about the containing object.",
197      useName = "remarks",
198      typeAdapter = MarkupMultilineAdapter.class
199  )
200  private MarkupMultiline _remarks;
201
202  /**
203   * Constructs a new {@code dev.metaschema.oscal.lib.model.Parameter} instance with no metadata.
204   */
205  public Parameter() {
206    this(null);
207  }
208
209  /**
210   * Constructs a new {@code dev.metaschema.oscal.lib.model.Parameter} instance with the specified metadata.
211   *
212   * @param data
213   *           the metaschema data, or {@code null} if none
214   */
215  public Parameter(IMetaschemaData data) {
216    this.__metaschemaData = data;
217  }
218
219  @Override
220  public IMetaschemaData getMetaschemaData() {
221    return __metaschemaData;
222  }
223
224  /**
225   * Get the "{@literal Parameter Identifier}".
226   *
227   * <p>
228   * A unique identifier for the parameter.
229   *
230   * @return the id value
231   */
232  @NonNull
233  public String getId() {
234    return _id;
235  }
236
237  /**
238   * Set the "{@literal Parameter Identifier}".
239   *
240   * <p>
241   * A unique identifier for the parameter.
242   *
243   * @param value
244   *           the id value to set
245   */
246  public void setId(@NonNull String value) {
247    _id = value;
248  }
249
250  /**
251   * Get the "{@literal Parameter Class}".
252   *
253   * <p>
254   * A textual label that provides a characterization of the type, purpose, use or scope of the parameter.
255   *
256   * @return the class value, or {@code null} if not set
257   */
258  @Nullable
259  public String getClazz() {
260    return _clazz;
261  }
262
263  /**
264   * Set the "{@literal Parameter Class}".
265   *
266   * <p>
267   * A textual label that provides a characterization of the type, purpose, use or scope of the parameter.
268   *
269   * @param value
270   *           the class value to set, or {@code null} to clear
271   */
272  public void setClazz(@Nullable String value) {
273    _clazz = value;
274  }
275
276  /**
277   * Get the "{@literal Depends on}".
278   *
279   * <p>
280   * <strong>(deprecated)</strong> Another parameter invoking this one. This construct has been deprecated and should not be used.
281   *
282   * @return the depends-on value, or {@code null} if not set
283   */
284  @Nullable
285  public String getDependsOn() {
286    return _dependsOn;
287  }
288
289  /**
290   * Set the "{@literal Depends on}".
291   *
292   * <p>
293   * <strong>(deprecated)</strong> Another parameter invoking this one. This construct has been deprecated and should not be used.
294   *
295   * @param value
296   *           the depends-on value to set, or {@code null} to clear
297   */
298  public void setDependsOn(@Nullable String value) {
299    _dependsOn = value;
300  }
301
302  /**
303   * Get the "{@literal Property}".
304   *
305   * <p>
306   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
307   *
308   * @return the prop value
309   */
310  @NonNull
311  public List<Property> getProps() {
312    if (_props == null) {
313      _props = new LinkedList<>();
314    }
315    return ObjectUtils.notNull(_props);
316  }
317
318  /**
319   * Set the "{@literal Property}".
320   *
321   * <p>
322   * An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.
323   *
324   * @param value
325   *           the prop value to set
326   */
327  public void setProps(@NonNull List<Property> value) {
328    _props = value;
329  }
330
331  /**
332   * Add a new {@link Property} item to the underlying collection.
333   * @param item the item to add
334   * @return {@code true}
335   */
336  public boolean addProp(Property item) {
337    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
338    if (_props == null) {
339      _props = new LinkedList<>();
340    }
341    return _props.add(value);
342  }
343
344  /**
345   * Remove the first matching {@link Property} item from the underlying collection.
346   * @param item the item to remove
347   * @return {@code true} if the item was removed or {@code false} otherwise
348   */
349  public boolean removeProp(Property item) {
350    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
351    return _props != null && _props.remove(value);
352  }
353
354  /**
355   * Get the "{@literal Link}".
356   *
357   * <p>
358   * A reference to a local or remote resource, that has a specific relation to the containing object.
359   *
360   * @return the link value
361   */
362  @NonNull
363  public List<Link> getLinks() {
364    if (_links == null) {
365      _links = new LinkedList<>();
366    }
367    return ObjectUtils.notNull(_links);
368  }
369
370  /**
371   * Set the "{@literal Link}".
372   *
373   * <p>
374   * A reference to a local or remote resource, that has a specific relation to the containing object.
375   *
376   * @param value
377   *           the link value to set
378   */
379  public void setLinks(@NonNull List<Link> value) {
380    _links = value;
381  }
382
383  /**
384   * Add a new {@link Link} item to the underlying collection.
385   * @param item the item to add
386   * @return {@code true}
387   */
388  public boolean addLink(Link item) {
389    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
390    if (_links == null) {
391      _links = new LinkedList<>();
392    }
393    return _links.add(value);
394  }
395
396  /**
397   * Remove the first matching {@link Link} item from the underlying collection.
398   * @param item the item to remove
399   * @return {@code true} if the item was removed or {@code false} otherwise
400   */
401  public boolean removeLink(Link item) {
402    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
403    return _links != null && _links.remove(value);
404  }
405
406  /**
407   * Get the "{@literal Parameter Label}".
408   *
409   * <p>
410   * A short, placeholder name for the parameter, which can be used as a substitute for a <code>value</code> if no value is assigned.
411   *
412   * @return the label value, or {@code null} if not set
413   */
414  @Nullable
415  public MarkupLine getLabel() {
416    return _label;
417  }
418
419  /**
420   * Set the "{@literal Parameter Label}".
421   *
422   * <p>
423   * A short, placeholder name for the parameter, which can be used as a substitute for a <code>value</code> if no value is assigned.
424   *
425   * @param value
426   *           the label value to set, or {@code null} to clear
427   */
428  public void setLabel(@Nullable MarkupLine value) {
429    _label = value;
430  }
431
432  /**
433   * Get the "{@literal Parameter Usage Description}".
434   *
435   * <p>
436   * Describes the purpose and use of a parameter.
437   *
438   * @return the usage value, or {@code null} if not set
439   */
440  @Nullable
441  public MarkupMultiline getUsage() {
442    return _usage;
443  }
444
445  /**
446   * Set the "{@literal Parameter Usage Description}".
447   *
448   * <p>
449   * Describes the purpose and use of a parameter.
450   *
451   * @param value
452   *           the usage value to set, or {@code null} to clear
453   */
454  public void setUsage(@Nullable MarkupMultiline value) {
455    _usage = value;
456  }
457
458  /**
459   * Get the "{@literal Constraint}".
460   *
461   * <p>
462   * A formal or informal expression of a constraint or test.
463   *
464   * @return the constraint value
465   */
466  @NonNull
467  public List<ParameterConstraint> getConstraints() {
468    if (_constraints == null) {
469      _constraints = new LinkedList<>();
470    }
471    return ObjectUtils.notNull(_constraints);
472  }
473
474  /**
475   * Set the "{@literal Constraint}".
476   *
477   * <p>
478   * A formal or informal expression of a constraint or test.
479   *
480   * @param value
481   *           the constraint value to set
482   */
483  public void setConstraints(@NonNull List<ParameterConstraint> value) {
484    _constraints = value;
485  }
486
487  /**
488   * Add a new {@link ParameterConstraint} item to the underlying collection.
489   * @param item the item to add
490   * @return {@code true}
491   */
492  public boolean addConstraint(ParameterConstraint item) {
493    ParameterConstraint value = ObjectUtils.requireNonNull(item,"item cannot be null");
494    if (_constraints == null) {
495      _constraints = new LinkedList<>();
496    }
497    return _constraints.add(value);
498  }
499
500  /**
501   * Remove the first matching {@link ParameterConstraint} item from the underlying collection.
502   * @param item the item to remove
503   * @return {@code true} if the item was removed or {@code false} otherwise
504   */
505  public boolean removeConstraint(ParameterConstraint item) {
506    ParameterConstraint value = ObjectUtils.requireNonNull(item,"item cannot be null");
507    return _constraints != null && _constraints.remove(value);
508  }
509
510  /**
511   * Get the "{@literal Guideline}".
512   *
513   * <p>
514   * A prose statement that provides a recommendation for the use of a parameter.
515   *
516   * @return the guideline value
517   */
518  @NonNull
519  public List<ParameterGuideline> getGuidelines() {
520    if (_guidelines == null) {
521      _guidelines = new LinkedList<>();
522    }
523    return ObjectUtils.notNull(_guidelines);
524  }
525
526  /**
527   * Set the "{@literal Guideline}".
528   *
529   * <p>
530   * A prose statement that provides a recommendation for the use of a parameter.
531   *
532   * @param value
533   *           the guideline value to set
534   */
535  public void setGuidelines(@NonNull List<ParameterGuideline> value) {
536    _guidelines = value;
537  }
538
539  /**
540   * Add a new {@link ParameterGuideline} item to the underlying collection.
541   * @param item the item to add
542   * @return {@code true}
543   */
544  public boolean addGuideline(ParameterGuideline item) {
545    ParameterGuideline value = ObjectUtils.requireNonNull(item,"item cannot be null");
546    if (_guidelines == null) {
547      _guidelines = new LinkedList<>();
548    }
549    return _guidelines.add(value);
550  }
551
552  /**
553   * Remove the first matching {@link ParameterGuideline} item from the underlying collection.
554   * @param item the item to remove
555   * @return {@code true} if the item was removed or {@code false} otherwise
556   */
557  public boolean removeGuideline(ParameterGuideline item) {
558    ParameterGuideline value = ObjectUtils.requireNonNull(item,"item cannot be null");
559    return _guidelines != null && _guidelines.remove(value);
560  }
561
562  /**
563   * Get the "{@literal Parameter Value}".
564   *
565   * <p>
566   * A parameter value or set of values.
567   *
568   * @return the value value
569   */
570  @NonNull
571  public List<String> getValues() {
572    if (_values == null) {
573      _values = new LinkedList<>();
574    }
575    return ObjectUtils.notNull(_values);
576  }
577
578  /**
579   * Set the "{@literal Parameter Value}".
580   *
581   * <p>
582   * A parameter value or set of values.
583   *
584   * @param value
585   *           the value value to set
586   */
587  public void setValues(@NonNull List<String> value) {
588    _values = value;
589  }
590
591  /**
592   * Add a new {@link String} item to the underlying collection.
593   * @param item the item to add
594   * @return {@code true}
595   */
596  public boolean addValue(String item) {
597    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
598    if (_values == null) {
599      _values = new LinkedList<>();
600    }
601    return _values.add(value);
602  }
603
604  /**
605   * Remove the first matching {@link String} item from the underlying collection.
606   * @param item the item to remove
607   * @return {@code true} if the item was removed or {@code false} otherwise
608   */
609  public boolean removeValue(String item) {
610    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
611    return _values != null && _values.remove(value);
612  }
613
614  /**
615   * Get the "{@literal Selection}".
616   *
617   * <p>
618   * Presenting a choice among alternatives.
619   *
620   * @return the select value, or {@code null} if not set
621   */
622  @Nullable
623  public ParameterSelection getSelect() {
624    return _select;
625  }
626
627  /**
628   * Set the "{@literal Selection}".
629   *
630   * <p>
631   * Presenting a choice among alternatives.
632   *
633   * @param value
634   *           the select value to set, or {@code null} to clear
635   */
636  public void setSelect(@Nullable ParameterSelection value) {
637    _select = value;
638  }
639
640  /**
641   * Get the "{@literal Remarks}".
642   *
643   * <p>
644   * Additional commentary about the containing object.
645   *
646   * @return the remarks value, or {@code null} if not set
647   */
648  @Nullable
649  public MarkupMultiline getRemarks() {
650    return _remarks;
651  }
652
653  /**
654   * Set the "{@literal Remarks}".
655   *
656   * <p>
657   * Additional commentary about the containing object.
658   *
659   * @param value
660   *           the remarks value to set, or {@code null} to clear
661   */
662  public void setRemarks(@Nullable MarkupMultiline value) {
663    _remarks = value;
664  }
665
666  @Override
667  public String toString() {
668    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
669  }
670}