001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
004import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine;
005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter;
006import gov.nist.secauto.metaschema.core.model.IBoundObject;
007import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
008import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
009import gov.nist.secauto.metaschema.core.util.ObjectUtils;
010import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
011import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
012import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
013import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
014import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
015import java.lang.Override;
016import java.lang.String;
017import java.util.LinkedList;
018import java.util.List;
019import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
020import org.apache.commons.lang3.builder.ToStringStyle;
021
022/**
023 * A group of (selected) controls or of groups of controls.
024 */
025@MetaschemaAssembly(
026    formalName = "Control Group",
027    description = "A group of (selected) controls or of groups of controls.",
028    name = "group",
029    moduleClass = OscalProfileModule.class,
030    remarks = "This construct mirrors the same construct that exists in an OSCAL catalog."
031)
032public class ProfileGroup implements IBoundObject {
033  private final IMetaschemaData __metaschemaData;
034
035  /**
036   * "Identifies the group."
037   */
038  @BoundFlag(
039      formalName = "Group Identifier",
040      description = "Identifies the group.",
041      name = "id",
042      typeAdapter = TokenAdapter.class,
043      remarks = "This optional data element is available to support hyperlinking to formal groups or families as defined in control catalogs, among other operations."
044  )
045  private String _id;
046
047  /**
048   * "A textual label that provides a sub-type or characterization of the group."
049   */
050  @BoundFlag(
051      formalName = "Group Class",
052      description = "A textual label that provides a sub-type or characterization of the group.",
053      name = "class",
054      typeAdapter = TokenAdapter.class,
055      remarks = "A `class` can be used in validation rules to express extra constraints over named items of a specific `class` value.\n"
056              + "\n"
057              + "A `class` can also be used in an OSCAL profile as a means to target an alteration to control content."
058  )
059  private String _clazz;
060
061  @BoundField(
062      formalName = "Group Title",
063      description = "A name to be given to the group for use in display.",
064      useName = "title",
065      minOccurs = 1,
066      typeAdapter = MarkupLineAdapter.class
067  )
068  private MarkupLine _title;
069
070  @BoundAssembly(
071      formalName = "Parameter",
072      description = "Parameters provide a mechanism for the dynamic assignment of value(s) in a control.",
073      useName = "param",
074      maxOccurs = -1,
075      groupAs = @GroupAs(name = "params", inJson = JsonGroupAsBehavior.LIST)
076  )
077  private List<Parameter> _params;
078
079  @BoundAssembly(
080      formalName = "Property",
081      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
082      useName = "prop",
083      maxOccurs = -1,
084      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
085  )
086  private List<Property> _props;
087
088  @BoundAssembly(
089      formalName = "Link",
090      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
091      useName = "link",
092      maxOccurs = -1,
093      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
094  )
095  private List<Link> _links;
096
097  @BoundAssembly(
098      formalName = "Part",
099      description = "An annotated, markup-based textual element of a control's or catalog group's definition, or a child of another part.",
100      useName = "part",
101      maxOccurs = -1,
102      groupAs = @GroupAs(name = "parts", inJson = JsonGroupAsBehavior.LIST)
103  )
104  private List<ControlPart> _parts;
105
106  @BoundAssembly(
107      formalName = "Control Group",
108      description = "A group of (selected) controls or of groups of controls.",
109      useName = "group",
110      maxOccurs = -1,
111      groupAs = @GroupAs(name = "groups", inJson = JsonGroupAsBehavior.LIST)
112  )
113  private List<ProfileGroup> _groups;
114
115  @BoundAssembly(
116      formalName = "Insert Controls",
117      description = "Specifies which controls to use in the containing context.",
118      useName = "insert-controls",
119      maxOccurs = -1,
120      groupAs = @GroupAs(name = "insert-controls", inJson = JsonGroupAsBehavior.LIST)
121  )
122  private List<InsertControls> _insertControls;
123
124  public ProfileGroup() {
125    this(null);
126  }
127
128  public ProfileGroup(IMetaschemaData data) {
129    this.__metaschemaData = data;
130  }
131
132  @Override
133  public IMetaschemaData getMetaschemaData() {
134    return __metaschemaData;
135  }
136
137  public String getId() {
138    return _id;
139  }
140
141  public void setId(String value) {
142    _id = value;
143  }
144
145  public String getClazz() {
146    return _clazz;
147  }
148
149  public void setClazz(String value) {
150    _clazz = value;
151  }
152
153  public MarkupLine getTitle() {
154    return _title;
155  }
156
157  public void setTitle(MarkupLine value) {
158    _title = value;
159  }
160
161  public List<Parameter> getParams() {
162    return _params;
163  }
164
165  public void setParams(List<Parameter> value) {
166    _params = value;
167  }
168
169  /**
170   * Add a new {@link Parameter} item to the underlying collection.
171   * @param item the item to add
172   * @return {@code true}
173   */
174  public boolean addParam(Parameter item) {
175    Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
176    if (_params == null) {
177      _params = new LinkedList<>();
178    }
179    return _params.add(value);
180  }
181
182  /**
183   * Remove the first matching {@link Parameter} item from the underlying collection.
184   * @param item the item to remove
185   * @return {@code true} if the item was removed or {@code false} otherwise
186   */
187  public boolean removeParam(Parameter item) {
188    Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
189    return _params != null && _params.remove(value);
190  }
191
192  public List<Property> getProps() {
193    return _props;
194  }
195
196  public void setProps(List<Property> value) {
197    _props = value;
198  }
199
200  /**
201   * Add a new {@link Property} item to the underlying collection.
202   * @param item the item to add
203   * @return {@code true}
204   */
205  public boolean addProp(Property item) {
206    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
207    if (_props == null) {
208      _props = new LinkedList<>();
209    }
210    return _props.add(value);
211  }
212
213  /**
214   * Remove the first matching {@link Property} item from the underlying collection.
215   * @param item the item to remove
216   * @return {@code true} if the item was removed or {@code false} otherwise
217   */
218  public boolean removeProp(Property item) {
219    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
220    return _props != null && _props.remove(value);
221  }
222
223  public List<Link> getLinks() {
224    return _links;
225  }
226
227  public void setLinks(List<Link> value) {
228    _links = value;
229  }
230
231  /**
232   * Add a new {@link Link} item to the underlying collection.
233   * @param item the item to add
234   * @return {@code true}
235   */
236  public boolean addLink(Link item) {
237    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
238    if (_links == null) {
239      _links = new LinkedList<>();
240    }
241    return _links.add(value);
242  }
243
244  /**
245   * Remove the first matching {@link Link} item from the underlying collection.
246   * @param item the item to remove
247   * @return {@code true} if the item was removed or {@code false} otherwise
248   */
249  public boolean removeLink(Link item) {
250    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
251    return _links != null && _links.remove(value);
252  }
253
254  public List<ControlPart> getParts() {
255    return _parts;
256  }
257
258  public void setParts(List<ControlPart> value) {
259    _parts = value;
260  }
261
262  /**
263   * Add a new {@link ControlPart} item to the underlying collection.
264   * @param item the item to add
265   * @return {@code true}
266   */
267  public boolean addPart(ControlPart item) {
268    ControlPart value = ObjectUtils.requireNonNull(item,"item cannot be null");
269    if (_parts == null) {
270      _parts = new LinkedList<>();
271    }
272    return _parts.add(value);
273  }
274
275  /**
276   * Remove the first matching {@link ControlPart} item from the underlying collection.
277   * @param item the item to remove
278   * @return {@code true} if the item was removed or {@code false} otherwise
279   */
280  public boolean removePart(ControlPart item) {
281    ControlPart value = ObjectUtils.requireNonNull(item,"item cannot be null");
282    return _parts != null && _parts.remove(value);
283  }
284
285  public List<ProfileGroup> getGroups() {
286    return _groups;
287  }
288
289  public void setGroups(List<ProfileGroup> value) {
290    _groups = value;
291  }
292
293  /**
294   * Add a new {@link ProfileGroup} item to the underlying collection.
295   * @param item the item to add
296   * @return {@code true}
297   */
298  public boolean addGroup(ProfileGroup item) {
299    ProfileGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
300    if (_groups == null) {
301      _groups = new LinkedList<>();
302    }
303    return _groups.add(value);
304  }
305
306  /**
307   * Remove the first matching {@link ProfileGroup} item from the underlying collection.
308   * @param item the item to remove
309   * @return {@code true} if the item was removed or {@code false} otherwise
310   */
311  public boolean removeGroup(ProfileGroup item) {
312    ProfileGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
313    return _groups != null && _groups.remove(value);
314  }
315
316  public List<InsertControls> getInsertControls() {
317    return _insertControls;
318  }
319
320  public void setInsertControls(List<InsertControls> value) {
321    _insertControls = value;
322  }
323
324  /**
325   * Add a new {@link InsertControls} item to the underlying collection.
326   * @param item the item to add
327   * @return {@code true}
328   */
329  public boolean addInsertControls(InsertControls item) {
330    InsertControls value = ObjectUtils.requireNonNull(item,"item cannot be null");
331    if (_insertControls == null) {
332      _insertControls = new LinkedList<>();
333    }
334    return _insertControls.add(value);
335  }
336
337  /**
338   * Remove the first matching {@link InsertControls} item from the underlying collection.
339   * @param item the item to remove
340   * @return {@code true} if the item was removed or {@code false} otherwise
341   */
342  public boolean removeInsertControls(InsertControls item) {
343    InsertControls value = ObjectUtils.requireNonNull(item,"item cannot be null");
344    return _insertControls != null && _insertControls.remove(value);
345  }
346
347  @Override
348  public String toString() {
349    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
350  }
351}