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.StringAdapter;
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   * A grouping of other components and/or capabilities.
29   */
30  @MetaschemaAssembly(
31      formalName = "Capability",
32      description = "A grouping of other components and/or capabilities.",
33      name = "capability",
34      metaschema = OscalComponentDefinitionMetaschema.class
35  )
36  @AssemblyConstraints(
37      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`.")
38  )
39  public class Capability {
40    @BoundFlag(
41        formalName = "Capability Identifier",
42        description = "Provides a globally unique means to identify a given capability.",
43        useName = "uuid",
44        required = true,
45        typeAdapter = UuidAdapter.class
46    )
47    private UUID _uuid;
48  
49    @BoundFlag(
50        formalName = "Capability Name",
51        description = "The capability's human-readable name.",
52        useName = "name",
53        required = true,
54        typeAdapter = StringAdapter.class
55    )
56    private String _name;
57  
58    /**
59     * "A summary of the capability."
60     */
61    @BoundField(
62        formalName = "Capability Description",
63        description = "A summary of the capability.",
64        useName = "description",
65        minOccurs = 1
66    )
67    @BoundFieldValue(
68        typeAdapter = MarkupMultilineAdapter.class
69    )
70    private MarkupMultiline _description;
71  
72    @BoundAssembly(
73        formalName = "Property",
74        description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
75        useName = "prop",
76        maxOccurs = -1
77    )
78    @GroupAs(
79        name = "props",
80        inJson = JsonGroupAsBehavior.LIST
81    )
82    private List<Property> _props;
83  
84    @BoundAssembly(
85        formalName = "Link",
86        description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
87        useName = "link",
88        maxOccurs = -1
89    )
90    @GroupAs(
91        name = "links",
92        inJson = JsonGroupAsBehavior.LIST
93    )
94    private List<Link> _links;
95  
96    @BoundAssembly(
97        formalName = "Incorporates Component",
98        description = "The collection of components comprising this capability.",
99        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 }