View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
4   import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
5   import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
6   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
7   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
8   import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
9   import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique;
10  import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
11  import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
12  import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
13  import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
14  import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
15  import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
16  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
17  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
18  import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
19  import java.lang.Override;
20  import java.lang.String;
21  import java.util.LinkedList;
22  import java.util.List;
23  import java.util.UUID;
24  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
25  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
26  
27  /**
28   * Identifies which statements within a control are addressed.
29   */
30  @MetaschemaAssembly(
31      formalName = "Control Statement Implementation",
32      description = "Identifies which statements within a control are addressed.",
33      name = "statement",
34      metaschema = OscalComponentDefinitionMetaschema.class
35  )
36  @AssemblyConstraints(
37      isUnique = @IsUnique(id = "unique-component-definition-statement-responsible-role", level = IConstraint.Level.ERROR, target = "responsible-role", keyFields = @KeyField(target = "@role-id"), remarks = "Since `responsible-role` associates multiple `party-uuid` entries with a single `role-id`, each role-id must be referenced only once.")
38  )
39  public class ComponentStatement {
40    @BoundFlag(
41        formalName = "Control Statement Reference",
42        description = "A [human-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented) identifier reference to a `control statement`.",
43        useName = "statement-id",
44        required = true,
45        typeAdapter = TokenAdapter.class,
46        remarks = "A reference to the specific implemented statement associated with a control."
47    )
48    private String _statementId;
49  
50    @BoundFlag(
51        formalName = "Control Statement Reference Universally Unique Identifier",
52        description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented), [globally unique](https://pages.nist.gov/OSCAL/concepts/identifier-use/#globally-unique) identifier with [cross-instance](https://pages.nist.gov/OSCAL/concepts/identifier-use/#cross-instance) scope that can be used to reference this control statement elsewhere in [this or other OSCAL instances](https://pages.nist.gov/OSCAL/concepts/identifier-use/#component-definition-identifiers). The *UUID* of the `control statement` in the source OSCAL instance is sufficient to reference the data item locally or globally (e.g., in an imported OSCAL instance).",
53        useName = "uuid",
54        required = true,
55        typeAdapter = UuidAdapter.class
56    )
57    private UUID _uuid;
58  
59    /**
60     * "A summary of how the containing control statement is implemented by the component or capability."
61     */
62    @BoundField(
63        formalName = "Statement Implementation Description",
64        description = "A summary of how the containing control statement is implemented by the component or capability.",
65        useName = "description",
66        minOccurs = 1
67    )
68    @BoundFieldValue(
69        typeAdapter = MarkupMultilineAdapter.class
70    )
71    private MarkupMultiline _description;
72  
73    @BoundAssembly(
74        formalName = "Property",
75        description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
76        useName = "prop",
77        maxOccurs = -1
78    )
79    @GroupAs(
80        name = "props",
81        inJson = JsonGroupAsBehavior.LIST
82    )
83    private List<Property> _props;
84  
85    @BoundAssembly(
86        formalName = "Link",
87        description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
88        useName = "link",
89        maxOccurs = -1
90    )
91    @GroupAs(
92        name = "links",
93        inJson = JsonGroupAsBehavior.LIST
94    )
95    private List<Link> _links;
96  
97    @BoundAssembly(
98        formalName = "Responsible Role",
99        description = "A reference to a role with responsibility for performing a function relative to the containing object, optionally associated with a set of persons and/or organizations that perform that role.",
100       useName = "responsible-role",
101       maxOccurs = -1
102   )
103   @GroupAs(
104       name = "responsible-roles",
105       inJson = JsonGroupAsBehavior.LIST
106   )
107   private List<ResponsibleRole> _responsibleRoles;
108 
109   @BoundField(
110       formalName = "Remarks",
111       description = "Additional commentary about the containing object.",
112       useName = "remarks"
113   )
114   @BoundFieldValue(
115       typeAdapter = MarkupMultilineAdapter.class
116   )
117   private MarkupMultiline _remarks;
118 
119   public ComponentStatement() {
120   }
121 
122   public String getStatementId() {
123     return _statementId;
124   }
125 
126   public void setStatementId(String value) {
127     _statementId = value;
128   }
129 
130   public UUID getUuid() {
131     return _uuid;
132   }
133 
134   public void setUuid(UUID value) {
135     _uuid = value;
136   }
137 
138   public MarkupMultiline getDescription() {
139     return _description;
140   }
141 
142   public void setDescription(MarkupMultiline value) {
143     _description = value;
144   }
145 
146   public List<Property> getProps() {
147     return _props;
148   }
149 
150   public void setProps(List<Property> value) {
151     _props = value;
152   }
153 
154   /**
155    * Add a new {@link Property} item to the underlying collection.
156    * @param item the item to add
157    * @return {@code true}
158    */
159   public boolean addProp(Property item) {
160     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
161     if (_props == null) {
162       _props = new LinkedList<>();
163     }
164     return _props.add(value);
165   }
166 
167   /**
168    * Remove the first matching {@link Property} item from the underlying collection.
169    * @param item the item to remove
170    * @return {@code true} if the item was removed or {@code false} otherwise
171    */
172   public boolean removeProp(Property item) {
173     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
174     return _props == null ? false : _props.remove(value);
175   }
176 
177   public List<Link> getLinks() {
178     return _links;
179   }
180 
181   public void setLinks(List<Link> value) {
182     _links = value;
183   }
184 
185   /**
186    * Add a new {@link Link} item to the underlying collection.
187    * @param item the item to add
188    * @return {@code true}
189    */
190   public boolean addLink(Link item) {
191     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
192     if (_links == null) {
193       _links = new LinkedList<>();
194     }
195     return _links.add(value);
196   }
197 
198   /**
199    * Remove the first matching {@link Link} item from the underlying collection.
200    * @param item the item to remove
201    * @return {@code true} if the item was removed or {@code false} otherwise
202    */
203   public boolean removeLink(Link item) {
204     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
205     return _links == null ? false : _links.remove(value);
206   }
207 
208   public List<ResponsibleRole> getResponsibleRoles() {
209     return _responsibleRoles;
210   }
211 
212   public void setResponsibleRoles(List<ResponsibleRole> value) {
213     _responsibleRoles = value;
214   }
215 
216   /**
217    * Add a new {@link ResponsibleRole} item to the underlying collection.
218    * @param item the item to add
219    * @return {@code true}
220    */
221   public boolean addResponsibleRole(ResponsibleRole item) {
222     ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null");
223     if (_responsibleRoles == null) {
224       _responsibleRoles = new LinkedList<>();
225     }
226     return _responsibleRoles.add(value);
227   }
228 
229   /**
230    * Remove the first matching {@link ResponsibleRole} item from the underlying collection.
231    * @param item the item to remove
232    * @return {@code true} if the item was removed or {@code false} otherwise
233    */
234   public boolean removeResponsibleRole(ResponsibleRole item) {
235     ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null");
236     return _responsibleRoles == null ? false : _responsibleRoles.remove(value);
237   }
238 
239   public MarkupMultiline getRemarks() {
240     return _remarks;
241   }
242 
243   public void setRemarks(MarkupMultiline value) {
244     _remarks = value;
245   }
246 
247   @Override
248   public String toString() {
249     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
250   }
251 }