View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
4   import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
5   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
6   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
7   import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
8   import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
9   import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
10  import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
11  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLine;
12  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLineAdapter;
13  import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
14  import java.lang.Override;
15  import java.lang.String;
16  import java.util.LinkedList;
17  import java.util.List;
18  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
19  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
20  
21  /**
22   * A group of (selected) controls or of groups of controls.
23   */
24  @MetaschemaAssembly(
25      formalName = "Control Group",
26      description = "A group of (selected) controls or of groups of controls.",
27      name = "group",
28      metaschema = OscalProfileMetaschema.class,
29      remarks = "This construct mirrors the same construct that exists in an OSCAL catalog."
30  )
31  public class ProfileGroup {
32    @BoundFlag(
33        formalName = "Group Identifier",
34        description = "Identifies the group.",
35        useName = "id",
36        typeAdapter = TokenAdapter.class,
37        remarks = "This optional data element is available to support hyperlinking to formal groups or families as defined in control catalogs, among other operations."
38    )
39    private String _id;
40  
41    @BoundFlag(
42        formalName = "Group Class",
43        description = "A textual label that provides a sub-type or characterization of the group.",
44        useName = "class",
45        typeAdapter = TokenAdapter.class,
46        remarks = "A `class` can be used in validation rules to express extra constraints over named items of a specific `class` value.\n"
47                + "\n"
48                + "A `class` can also be used in an OSCAL profile as a means to target an alteration to control content."
49    )
50    private String _clazz;
51  
52    /**
53     * "A name to be given to the group for use in display."
54     */
55    @BoundField(
56        formalName = "Group Title",
57        description = "A name to be given to the group for use in display.",
58        useName = "title",
59        minOccurs = 1
60    )
61    @BoundFieldValue(
62        typeAdapter = MarkupLineAdapter.class
63    )
64    private MarkupLine _title;
65  
66    @BoundAssembly(
67        formalName = "Parameter",
68        description = "Parameters provide a mechanism for the dynamic assignment of value(s) in a control.",
69        useName = "param",
70        maxOccurs = -1
71    )
72    @GroupAs(
73        name = "params",
74        inJson = JsonGroupAsBehavior.LIST
75    )
76    private List<Parameter> _params;
77  
78    @BoundAssembly(
79        formalName = "Property",
80        description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
81        useName = "prop",
82        maxOccurs = -1
83    )
84    @GroupAs(
85        name = "props",
86        inJson = JsonGroupAsBehavior.LIST
87    )
88    private List<Property> _props;
89  
90    @BoundAssembly(
91        formalName = "Link",
92        description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
93        useName = "link",
94        maxOccurs = -1
95    )
96    @GroupAs(
97        name = "links",
98        inJson = JsonGroupAsBehavior.LIST
99    )
100   private List<Link> _links;
101 
102   @BoundAssembly(
103       formalName = "Part",
104       description = "An annotated, markup-based textual element of a control's or catalog group's definition, or a child of another part.",
105       useName = "part",
106       maxOccurs = -1
107   )
108   @GroupAs(
109       name = "parts",
110       inJson = JsonGroupAsBehavior.LIST
111   )
112   private List<ControlPart> _parts;
113 
114   @BoundAssembly(
115       formalName = "Control Group",
116       description = "A group of (selected) controls or of groups of controls.",
117       useName = "group",
118       maxOccurs = -1
119   )
120   @GroupAs(
121       name = "groups",
122       inJson = JsonGroupAsBehavior.LIST
123   )
124   private List<ProfileGroup> _groups;
125 
126   @BoundAssembly(
127       formalName = "Insert Controls",
128       description = "Specifies which controls to use in the containing context.",
129       useName = "insert-controls",
130       maxOccurs = -1
131   )
132   @GroupAs(
133       name = "insert-controls",
134       inJson = JsonGroupAsBehavior.LIST
135   )
136   private List<InsertControls> _insertControls;
137 
138   public ProfileGroup() {
139   }
140 
141   public String getId() {
142     return _id;
143   }
144 
145   public void setId(String value) {
146     _id = value;
147   }
148 
149   public String getClazz() {
150     return _clazz;
151   }
152 
153   public void setClazz(String value) {
154     _clazz = value;
155   }
156 
157   public MarkupLine getTitle() {
158     return _title;
159   }
160 
161   public void setTitle(MarkupLine value) {
162     _title = value;
163   }
164 
165   public List<Parameter> getParams() {
166     return _params;
167   }
168 
169   public void setParams(List<Parameter> value) {
170     _params = value;
171   }
172 
173   /**
174    * Add a new {@link Parameter} item to the underlying collection.
175    * @param item the item to add
176    * @return {@code true}
177    */
178   public boolean addParam(Parameter item) {
179     Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
180     if (_params == null) {
181       _params = new LinkedList<>();
182     }
183     return _params.add(value);
184   }
185 
186   /**
187    * Remove the first matching {@link Parameter} item from the underlying collection.
188    * @param item the item to remove
189    * @return {@code true} if the item was removed or {@code false} otherwise
190    */
191   public boolean removeParam(Parameter item) {
192     Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
193     return _params == null ? false : _params.remove(value);
194   }
195 
196   public List<Property> getProps() {
197     return _props;
198   }
199 
200   public void setProps(List<Property> value) {
201     _props = value;
202   }
203 
204   /**
205    * Add a new {@link Property} item to the underlying collection.
206    * @param item the item to add
207    * @return {@code true}
208    */
209   public boolean addProp(Property item) {
210     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
211     if (_props == null) {
212       _props = new LinkedList<>();
213     }
214     return _props.add(value);
215   }
216 
217   /**
218    * Remove the first matching {@link Property} item from the underlying collection.
219    * @param item the item to remove
220    * @return {@code true} if the item was removed or {@code false} otherwise
221    */
222   public boolean removeProp(Property item) {
223     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
224     return _props == null ? false : _props.remove(value);
225   }
226 
227   public List<Link> getLinks() {
228     return _links;
229   }
230 
231   public void setLinks(List<Link> value) {
232     _links = value;
233   }
234 
235   /**
236    * Add a new {@link Link} item to the underlying collection.
237    * @param item the item to add
238    * @return {@code true}
239    */
240   public boolean addLink(Link item) {
241     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
242     if (_links == null) {
243       _links = new LinkedList<>();
244     }
245     return _links.add(value);
246   }
247 
248   /**
249    * Remove the first matching {@link Link} item from the underlying collection.
250    * @param item the item to remove
251    * @return {@code true} if the item was removed or {@code false} otherwise
252    */
253   public boolean removeLink(Link item) {
254     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
255     return _links == null ? false : _links.remove(value);
256   }
257 
258   public List<ControlPart> getParts() {
259     return _parts;
260   }
261 
262   public void setParts(List<ControlPart> value) {
263     _parts = value;
264   }
265 
266   /**
267    * Add a new {@link ControlPart} item to the underlying collection.
268    * @param item the item to add
269    * @return {@code true}
270    */
271   public boolean addPart(ControlPart item) {
272     ControlPart value = ObjectUtils.requireNonNull(item,"item cannot be null");
273     if (_parts == null) {
274       _parts = new LinkedList<>();
275     }
276     return _parts.add(value);
277   }
278 
279   /**
280    * Remove the first matching {@link ControlPart} item from the underlying collection.
281    * @param item the item to remove
282    * @return {@code true} if the item was removed or {@code false} otherwise
283    */
284   public boolean removePart(ControlPart item) {
285     ControlPart value = ObjectUtils.requireNonNull(item,"item cannot be null");
286     return _parts == null ? false : _parts.remove(value);
287   }
288 
289   public List<ProfileGroup> getGroups() {
290     return _groups;
291   }
292 
293   public void setGroups(List<ProfileGroup> value) {
294     _groups = value;
295   }
296 
297   /**
298    * Add a new {@link ProfileGroup} item to the underlying collection.
299    * @param item the item to add
300    * @return {@code true}
301    */
302   public boolean addGroup(ProfileGroup item) {
303     ProfileGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
304     if (_groups == null) {
305       _groups = new LinkedList<>();
306     }
307     return _groups.add(value);
308   }
309 
310   /**
311    * Remove the first matching {@link ProfileGroup} item from the underlying collection.
312    * @param item the item to remove
313    * @return {@code true} if the item was removed or {@code false} otherwise
314    */
315   public boolean removeGroup(ProfileGroup item) {
316     ProfileGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
317     return _groups == null ? false : _groups.remove(value);
318   }
319 
320   public List<InsertControls> getInsertControls() {
321     return _insertControls;
322   }
323 
324   public void setInsertControls(List<InsertControls> value) {
325     _insertControls = value;
326   }
327 
328   /**
329    * Add a new {@link InsertControls} item to the underlying collection.
330    * @param item the item to add
331    * @return {@code true}
332    */
333   public boolean addInsertControls(InsertControls item) {
334     InsertControls value = ObjectUtils.requireNonNull(item,"item cannot be null");
335     if (_insertControls == null) {
336       _insertControls = new LinkedList<>();
337     }
338     return _insertControls.add(value);
339   }
340 
341   /**
342    * Remove the first matching {@link InsertControls} item from the underlying collection.
343    * @param item the item to remove
344    * @return {@code true} if the item was removed or {@code false} otherwise
345    */
346   public boolean removeInsertControls(InsertControls item) {
347     InsertControls value = ObjectUtils.requireNonNull(item,"item cannot be null");
348     return _insertControls == null ? false : _insertControls.remove(value);
349   }
350 
351   @Override
352   public String toString() {
353     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
354   }
355 }