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.StringAdapter;
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 * A grouping of other components and/or capabilities.
029 */
030@MetaschemaAssembly(
031    formalName = "Capability",
032    description = "A grouping of other components and/or capabilities.",
033    name = "capability",
034    metaschema = OscalComponentDefinitionMetaschema.class
035)
036@AssemblyConstraints(
037    isUnique = @IsUnique(id = "unique-component-definition-capability-incorporates-component", level = IConstraint.Level.ERROR, target = "incorporates-component", keyFields = @KeyField(target = "@component-uuid"), remarks = "A given `component` must not be referenced more than once within the same `capability`.")
038)
039public class Capability {
040  @BoundFlag(
041      formalName = "Capability Identifier",
042      description = "Provides a globally unique means to identify a given capability.",
043      useName = "uuid",
044      required = true,
045      typeAdapter = UuidAdapter.class
046  )
047  private UUID _uuid;
048
049  @BoundFlag(
050      formalName = "Capability Name",
051      description = "The capability's human-readable name.",
052      useName = "name",
053      required = true,
054      typeAdapter = StringAdapter.class
055  )
056  private String _name;
057
058  /**
059   * "A summary of the capability."
060   */
061  @BoundField(
062      formalName = "Capability Description",
063      description = "A summary of the capability.",
064      useName = "description",
065      minOccurs = 1
066  )
067  @BoundFieldValue(
068      typeAdapter = MarkupMultilineAdapter.class
069  )
070  private MarkupMultiline _description;
071
072  @BoundAssembly(
073      formalName = "Property",
074      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
075      useName = "prop",
076      maxOccurs = -1
077  )
078  @GroupAs(
079      name = "props",
080      inJson = JsonGroupAsBehavior.LIST
081  )
082  private List<Property> _props;
083
084  @BoundAssembly(
085      formalName = "Link",
086      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
087      useName = "link",
088      maxOccurs = -1
089  )
090  @GroupAs(
091      name = "links",
092      inJson = JsonGroupAsBehavior.LIST
093  )
094  private List<Link> _links;
095
096  @BoundAssembly(
097      formalName = "Incorporates Component",
098      description = "The collection of components comprising this capability.",
099      useName = "incorporates-component",
100      maxOccurs = -1
101  )
102  @GroupAs(
103      name = "incorporates-components",
104      inJson = JsonGroupAsBehavior.LIST
105  )
106  private List<IncorporatesComponent> _incorporatesComponents;
107
108  @BoundAssembly(
109      formalName = "Control Implementation Set",
110      description = "Defines how the component or capability supports a set of controls.",
111      useName = "control-implementation",
112      maxOccurs = -1
113  )
114  @GroupAs(
115      name = "control-implementations",
116      inJson = JsonGroupAsBehavior.LIST
117  )
118  private List<ComponentControlImplementation> _controlImplementations;
119
120  @BoundField(
121      formalName = "Remarks",
122      description = "Additional commentary about the containing object.",
123      useName = "remarks"
124  )
125  @BoundFieldValue(
126      typeAdapter = MarkupMultilineAdapter.class
127  )
128  private MarkupMultiline _remarks;
129
130  public Capability() {
131  }
132
133  public UUID getUuid() {
134    return _uuid;
135  }
136
137  public void setUuid(UUID value) {
138    _uuid = value;
139  }
140
141  public String getName() {
142    return _name;
143  }
144
145  public void setName(String value) {
146    _name = value;
147  }
148
149  public MarkupMultiline getDescription() {
150    return _description;
151  }
152
153  public void setDescription(MarkupMultiline value) {
154    _description = value;
155  }
156
157  public List<Property> getProps() {
158    return _props;
159  }
160
161  public void setProps(List<Property> value) {
162    _props = value;
163  }
164
165  /**
166   * Add a new {@link Property} item to the underlying collection.
167   * @param item the item to add
168   * @return {@code true}
169   */
170  public boolean addProp(Property item) {
171    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
172    if (_props == null) {
173      _props = new LinkedList<>();
174    }
175    return _props.add(value);
176  }
177
178  /**
179   * Remove the first matching {@link Property} item from the underlying collection.
180   * @param item the item to remove
181   * @return {@code true} if the item was removed or {@code false} otherwise
182   */
183  public boolean removeProp(Property item) {
184    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
185    return _props == null ? false : _props.remove(value);
186  }
187
188  public List<Link> getLinks() {
189    return _links;
190  }
191
192  public void setLinks(List<Link> value) {
193    _links = value;
194  }
195
196  /**
197   * Add a new {@link Link} item to the underlying collection.
198   * @param item the item to add
199   * @return {@code true}
200   */
201  public boolean addLink(Link item) {
202    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
203    if (_links == null) {
204      _links = new LinkedList<>();
205    }
206    return _links.add(value);
207  }
208
209  /**
210   * Remove the first matching {@link Link} item from the underlying collection.
211   * @param item the item to remove
212   * @return {@code true} if the item was removed or {@code false} otherwise
213   */
214  public boolean removeLink(Link item) {
215    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
216    return _links == null ? false : _links.remove(value);
217  }
218
219  public List<IncorporatesComponent> getIncorporatesComponents() {
220    return _incorporatesComponents;
221  }
222
223  public void setIncorporatesComponents(List<IncorporatesComponent> value) {
224    _incorporatesComponents = value;
225  }
226
227  /**
228   * Add a new {@link IncorporatesComponent} item to the underlying collection.
229   * @param item the item to add
230   * @return {@code true}
231   */
232  public boolean addIncorporatesComponent(IncorporatesComponent item) {
233    IncorporatesComponent value = ObjectUtils.requireNonNull(item,"item cannot be null");
234    if (_incorporatesComponents == null) {
235      _incorporatesComponents = new LinkedList<>();
236    }
237    return _incorporatesComponents.add(value);
238  }
239
240  /**
241   * Remove the first matching {@link IncorporatesComponent} item from the underlying collection.
242   * @param item the item to remove
243   * @return {@code true} if the item was removed or {@code false} otherwise
244   */
245  public boolean removeIncorporatesComponent(IncorporatesComponent item) {
246    IncorporatesComponent value = ObjectUtils.requireNonNull(item,"item cannot be null");
247    return _incorporatesComponents == null ? false : _incorporatesComponents.remove(value);
248  }
249
250  public List<ComponentControlImplementation> getControlImplementations() {
251    return _controlImplementations;
252  }
253
254  public void setControlImplementations(List<ComponentControlImplementation> value) {
255    _controlImplementations = value;
256  }
257
258  /**
259   * Add a new {@link ComponentControlImplementation} item to the underlying collection.
260   * @param item the item to add
261   * @return {@code true}
262   */
263  public boolean addControlImplementation(ComponentControlImplementation item) {
264    ComponentControlImplementation value = ObjectUtils.requireNonNull(item,"item cannot be null");
265    if (_controlImplementations == null) {
266      _controlImplementations = new LinkedList<>();
267    }
268    return _controlImplementations.add(value);
269  }
270
271  /**
272   * Remove the first matching {@link ComponentControlImplementation} item from the underlying collection.
273   * @param item the item to remove
274   * @return {@code true} if the item was removed or {@code false} otherwise
275   */
276  public boolean removeControlImplementation(ComponentControlImplementation item) {
277    ComponentControlImplementation value = ObjectUtils.requireNonNull(item,"item cannot be null");
278    return _controlImplementations == null ? false : _controlImplementations.remove(value);
279  }
280
281  public MarkupMultiline getRemarks() {
282    return _remarks;
283  }
284
285  public void setRemarks(MarkupMultiline value) {
286    _remarks = value;
287  }
288
289  @Override
290  public String toString() {
291    return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
292  }
293}