001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
004import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
005import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
006import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
007import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
008import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
009import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique;
010import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
011import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
012import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
013import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
014import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
015import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
016import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
017import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
018import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
019import java.lang.Override;
020import java.lang.String;
021import java.util.LinkedList;
022import java.util.List;
023import java.util.UUID;
024import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
025import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
026
027/**
028 * Identifies which statements within a control are addressed.
029 */
030@MetaschemaAssembly(
031    formalName = "Control Statement Implementation",
032    description = "Identifies which statements within a control are addressed.",
033    name = "statement",
034    metaschema = OscalComponentDefinitionMetaschema.class
035)
036@AssemblyConstraints(
037    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.")
038)
039public class ComponentStatement {
040  @BoundFlag(
041      formalName = "Control Statement Reference",
042      description = "A [human-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented) identifier reference to a `control statement`.",
043      useName = "statement-id",
044      required = true,
045      typeAdapter = TokenAdapter.class,
046      remarks = "A reference to the specific implemented statement associated with a control."
047  )
048  private String _statementId;
049
050  @BoundFlag(
051      formalName = "Control Statement Reference Universally Unique Identifier",
052      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).",
053      useName = "uuid",
054      required = true,
055      typeAdapter = UuidAdapter.class
056  )
057  private UUID _uuid;
058
059  /**
060   * "A summary of how the containing control statement is implemented by the component or capability."
061   */
062  @BoundField(
063      formalName = "Statement Implementation Description",
064      description = "A summary of how the containing control statement is implemented by the component or capability.",
065      useName = "description",
066      minOccurs = 1
067  )
068  @BoundFieldValue(
069      typeAdapter = MarkupMultilineAdapter.class
070  )
071  private MarkupMultiline _description;
072
073  @BoundAssembly(
074      formalName = "Property",
075      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
076      useName = "prop",
077      maxOccurs = -1
078  )
079  @GroupAs(
080      name = "props",
081      inJson = JsonGroupAsBehavior.LIST
082  )
083  private List<Property> _props;
084
085  @BoundAssembly(
086      formalName = "Link",
087      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
088      useName = "link",
089      maxOccurs = -1
090  )
091  @GroupAs(
092      name = "links",
093      inJson = JsonGroupAsBehavior.LIST
094  )
095  private List<Link> _links;
096
097  @BoundAssembly(
098      formalName = "Responsible Role",
099      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}