001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
004import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
005import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
006import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
007import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
008import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
009import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
010import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
011import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLine;
012import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLineAdapter;
013import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
014import java.lang.Override;
015import java.lang.String;
016import java.util.LinkedList;
017import java.util.List;
018import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
019import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
020
021/**
022 * A group of (selected) controls or of groups of controls.
023 */
024@MetaschemaAssembly(
025    formalName = "Control Group",
026    description = "A group of (selected) controls or of groups of controls.",
027    name = "group",
028    metaschema = OscalProfileMetaschema.class,
029    remarks = "This construct mirrors the same construct that exists in an OSCAL catalog."
030)
031public class ProfileGroup {
032  @BoundFlag(
033      formalName = "Group Identifier",
034      description = "Identifies the group.",
035      useName = "id",
036      typeAdapter = TokenAdapter.class,
037      remarks = "This optional data element is available to support hyperlinking to formal groups or families as defined in control catalogs, among other operations."
038  )
039  private String _id;
040
041  @BoundFlag(
042      formalName = "Group Class",
043      description = "A textual label that provides a sub-type or characterization of the group.",
044      useName = "class",
045      typeAdapter = TokenAdapter.class,
046      remarks = "A `class` can be used in validation rules to express extra constraints over named items of a specific `class` value.\n"
047              + "\n"
048              + "A `class` can also be used in an OSCAL profile as a means to target an alteration to control content."
049  )
050  private String _clazz;
051
052  /**
053   * "A name to be given to the group for use in display."
054   */
055  @BoundField(
056      formalName = "Group Title",
057      description = "A name to be given to the group for use in display.",
058      useName = "title",
059      minOccurs = 1
060  )
061  @BoundFieldValue(
062      typeAdapter = MarkupLineAdapter.class
063  )
064  private MarkupLine _title;
065
066  @BoundAssembly(
067      formalName = "Parameter",
068      description = "Parameters provide a mechanism for the dynamic assignment of value(s) in a control.",
069      useName = "param",
070      maxOccurs = -1
071  )
072  @GroupAs(
073      name = "params",
074      inJson = JsonGroupAsBehavior.LIST
075  )
076  private List<Parameter> _params;
077
078  @BoundAssembly(
079      formalName = "Property",
080      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
081      useName = "prop",
082      maxOccurs = -1
083  )
084  @GroupAs(
085      name = "props",
086      inJson = JsonGroupAsBehavior.LIST
087  )
088  private List<Property> _props;
089
090  @BoundAssembly(
091      formalName = "Link",
092      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
093      useName = "link",
094      maxOccurs = -1
095  )
096  @GroupAs(
097      name = "links",
098      inJson = JsonGroupAsBehavior.LIST
099  )
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}