View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
4   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
5   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
6   import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
7   import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
8   import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
9   import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
10  import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
11  import java.lang.Override;
12  import java.lang.String;
13  import java.util.LinkedList;
14  import java.util.List;
15  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
16  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
17  
18  /**
19   * Used to select a control for inclusion/exclusion based on one or more control identifiers. A set of statement identifiers can be used to target the inclusion/exclusion to only specific control statements providing more granularity over the specific statements that are within the asessment scope.
20   */
21  @MetaschemaAssembly(
22      formalName = "Select Control",
23      description = "Used to select a control for inclusion/exclusion based on one or more control identifiers. A set of statement identifiers can be used to target the inclusion/exclusion to only specific control statements providing more granularity over the specific statements that are within the asessment scope.",
24      name = "select-control-by-id",
25      metaschema = OscalAssessmentCommonMetaschema.class
26  )
27  public class SelectControlById {
28    @BoundFlag(
29        formalName = "Control Identifier Reference",
30        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).",
31        useName = "control-id",
32        required = true,
33        typeAdapter = TokenAdapter.class
34    )
35    private String _controlId;
36  
37    /**
38     * "Used to constrain the selection to only specificity identified statements."
39     */
40    @BoundField(
41        formalName = "Include Specific Statements",
42        description = "Used to constrain the selection to only specificity identified statements.",
43        useName = "statement-id",
44        maxOccurs = -1
45    )
46    @BoundFieldValue(
47        typeAdapter = TokenAdapter.class
48    )
49    @GroupAs(
50        name = "statement-ids",
51        inJson = JsonGroupAsBehavior.LIST
52    )
53    private List<String> _statementIds;
54  
55    public SelectControlById() {
56    }
57  
58    public String getControlId() {
59      return _controlId;
60    }
61  
62    public void setControlId(String value) {
63      _controlId = value;
64    }
65  
66    public List<String> getStatementIds() {
67      return _statementIds;
68    }
69  
70    public void setStatementIds(List<String> value) {
71      _statementIds = value;
72    }
73  
74    /**
75     * Add a new {@link String} item to the underlying collection.
76     * @param item the item to add
77     * @return {@code true}
78     */
79    public boolean addStatementId(String item) {
80      String value = ObjectUtils.requireNonNull(item,"item cannot be null");
81      if (_statementIds == null) {
82        _statementIds = new LinkedList<>();
83      }
84      return _statementIds.add(value);
85    }
86  
87    /**
88     * Remove the first matching {@link String} item from the underlying collection.
89     * @param item the item to remove
90     * @return {@code true} if the item was removed or {@code false} otherwise
91     */
92    public boolean removeStatementId(String item) {
93      String value = ObjectUtils.requireNonNull(item,"item cannot be null");
94      return _statementIds == null ? false : _statementIds.remove(value);
95    }
96  
97    @Override
98    public String toString() {
99      return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
100   }
101 }