001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_profile_metaschema.xml
002// Do not edit - changes will be lost when regenerated.
003package dev.metaschema.oscal.lib.model;
004
005import dev.metaschema.core.datatype.adapter.BooleanAdapter;
006import dev.metaschema.core.datatype.adapter.StringAdapter;
007import dev.metaschema.core.model.IBoundObject;
008import dev.metaschema.core.model.IMetaschemaData;
009import dev.metaschema.core.model.JsonGroupAsBehavior;
010import dev.metaschema.core.model.constraint.IConstraint;
011import dev.metaschema.core.util.ObjectUtils;
012import dev.metaschema.databind.model.annotations.AllowedValue;
013import dev.metaschema.databind.model.annotations.AllowedValues;
014import dev.metaschema.databind.model.annotations.BoundAssembly;
015import dev.metaschema.databind.model.annotations.BoundChoice;
016import dev.metaschema.databind.model.annotations.BoundField;
017import dev.metaschema.databind.model.annotations.BoundFlag;
018import dev.metaschema.databind.model.annotations.Expect;
019import dev.metaschema.databind.model.annotations.GroupAs;
020import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
021import dev.metaschema.databind.model.annotations.ValueConstraints;
022import edu.umd.cs.findbugs.annotations.NonNull;
023import edu.umd.cs.findbugs.annotations.Nullable;
024import java.util.LinkedList;
025import java.util.List;
026import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
027import org.apache.commons.lang3.builder.ToStringStyle;
028
029/**
030 * Provides structuring directives that instruct how controls are organized after profile resolution.
031 */
032@MetaschemaAssembly(
033    formalName = "Merge Controls",
034    description = "Provides structuring directives that instruct how controls are organized after profile resolution.",
035    name = "merge",
036    moduleClass = OscalProfileModule.class
037)
038public class Merge implements IBoundObject {
039  private final IMetaschemaData __metaschemaData;
040
041  /**
042   * A Combine element defines how to resolve duplicate instances of the same control (e.g., controls with the same ID).
043   */
044  @BoundAssembly(
045      formalName = "Combination Rule",
046      description = "A Combine element defines how to resolve duplicate instances of the same control (e.g., controls with the same ID).",
047      useName = "combine"
048  )
049  private Combine _combine;
050
051  /**
052   * Directs that controls appear without any grouping structure.
053   */
054  @BoundAssembly(
055      formalName = "Flat Without Grouping",
056      description = "Directs that controls appear without any grouping structure.",
057      useName = "flat",
058      minOccurs = 1
059  )
060  @BoundChoice(
061      choiceId = "choice-1"
062  )
063  private Flat _flat;
064
065  /**
066   * Indicates that the controls selected should retain their original grouping as defined in the import source.
067   */
068  @BoundField(
069      formalName = "Group As-Is",
070      description = "Indicates that the controls selected should retain their original grouping as defined in the import source.",
071      useName = "as-is",
072      minOccurs = 1,
073      typeAdapter = BooleanAdapter.class
074  )
075  @BoundChoice(
076      choiceId = "choice-1"
077  )
078  private Boolean _asIs;
079
080  /**
081   * Provides an alternate grouping structure that selected controls will be placed in.
082   */
083  @BoundAssembly(
084      formalName = "Custom Grouping",
085      description = "Provides an alternate grouping structure that selected controls will be placed in.",
086      useName = "custom",
087      remarks = "The `custom` element represents a custom arrangement or organization of controls in the resolution of a catalog. This structuring directive gives the profile author the ability to define an entirely different organization of controls as compared to their source catalog(s).",
088      minOccurs = 1
089  )
090  @BoundChoice(
091      choiceId = "choice-1"
092  )
093  private Custom _custom;
094
095  /**
096   * Constructs a new {@code dev.metaschema.oscal.lib.model.Merge} instance with no metadata.
097   */
098  public Merge() {
099    this(null);
100  }
101
102  /**
103   * Constructs a new {@code dev.metaschema.oscal.lib.model.Merge} instance with the specified metadata.
104   *
105   * @param data
106   *           the metaschema data, or {@code null} if none
107   */
108  public Merge(IMetaschemaData data) {
109    this.__metaschemaData = data;
110  }
111
112  @Override
113  public IMetaschemaData getMetaschemaData() {
114    return __metaschemaData;
115  }
116
117  /**
118   * Get the "{@literal Combination Rule}".
119   *
120   * <p>
121   * A Combine element defines how to resolve duplicate instances of the same control (e.g., controls with the same ID).
122   *
123   * @return the combine value, or {@code null} if not set
124   */
125  @Nullable
126  public Combine getCombine() {
127    return _combine;
128  }
129
130  /**
131   * Set the "{@literal Combination Rule}".
132   *
133   * <p>
134   * A Combine element defines how to resolve duplicate instances of the same control (e.g., controls with the same ID).
135   *
136   * @param value
137   *           the combine value to set, or {@code null} to clear
138   */
139  public void setCombine(@Nullable Combine value) {
140    _combine = value;
141  }
142
143  /**
144   * Get the "{@literal Flat Without Grouping}".
145   *
146   * <p>
147   * Directs that controls appear without any grouping structure.
148   *
149   * @return the flat value, or {@code null} if not set
150   */
151  @Nullable
152  public Flat getFlat() {
153    return _flat;
154  }
155
156  /**
157   * Set the "{@literal Flat Without Grouping}".
158   *
159   * <p>
160   * Directs that controls appear without any grouping structure.
161   *
162   * @param value
163   *           the flat value to set, or {@code null} to clear
164   */
165  public void setFlat(@Nullable Flat value) {
166    _flat = value;
167  }
168
169  /**
170   * Get the "{@literal Group As-Is}".
171   *
172   * <p>
173   * Indicates that the controls selected should retain their original grouping as defined in the import source.
174   *
175   * @return the as-is value, or {@code null} if not set
176   */
177  @Nullable
178  public Boolean getAsIs() {
179    return _asIs;
180  }
181
182  /**
183   * Set the "{@literal Group As-Is}".
184   *
185   * <p>
186   * Indicates that the controls selected should retain their original grouping as defined in the import source.
187   *
188   * @param value
189   *           the as-is value to set, or {@code null} to clear
190   */
191  public void setAsIs(@Nullable Boolean value) {
192    _asIs = value;
193  }
194
195  /**
196   * Get the "{@literal Custom Grouping}".
197   *
198   * <p>
199   * Provides an alternate grouping structure that selected controls will be placed in.
200   *
201   * @return the custom value, or {@code null} if not set
202   */
203  @Nullable
204  public Custom getCustom() {
205    return _custom;
206  }
207
208  /**
209   * Set the "{@literal Custom Grouping}".
210   *
211   * <p>
212   * Provides an alternate grouping structure that selected controls will be placed in.
213   *
214   * @param value
215   *           the custom value to set, or {@code null} to clear
216   */
217  public void setCustom(@Nullable Custom value) {
218    _custom = value;
219  }
220
221  @Override
222  public String toString() {
223    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
224  }
225
226  /**
227   * A Combine element defines how to resolve duplicate instances of the same control (e.g., controls with the same ID).
228   */
229  @MetaschemaAssembly(
230      formalName = "Combination Rule",
231      description = "A Combine element defines how to resolve duplicate instances of the same control (e.g., controls with the same ID).",
232      name = "combine",
233      moduleClass = OscalProfileModule.class,
234      valueConstraints = @ValueConstraints(expect = @Expect(id = "oscal-profile-req-merge-combine", level = IConstraint.Level.ERROR, test = "not(@method='merge')"))
235  )
236  public static class Combine implements IBoundObject {
237    private final IMetaschemaData __metaschemaData;
238
239    /**
240     * Declare how clashing controls should be handled.
241     */
242    @BoundFlag(
243        formalName = "Combination Method",
244        description = "Declare how clashing controls should be handled.",
245        name = "method",
246        typeAdapter = StringAdapter.class,
247        valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(id = "oscal-profile-merge-combine-method-values", level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "use-first", description = "Use the first definition - the first control with a given ID is used; subsequent ones are discarded"), @AllowedValue(value = "merge", description = "\\*\\*(*deprecated* )\\*\\* \\*\\*(*unspecified*)\\*\\* Merge - controls with the same ID are combined", deprecatedVersion = "1.0.1"), @AllowedValue(value = "keep", description = "Keep - controls with the same ID are kept, retaining the clash")}))
248    )
249    private String _method;
250
251    /**
252     * Constructs a new {@code dev.metaschema.oscal.lib.model.Merge.Combine} instance with no metadata.
253     */
254    public Combine() {
255      this(null);
256    }
257
258    /**
259     * Constructs a new {@code dev.metaschema.oscal.lib.model.Merge.Combine} instance with the specified metadata.
260     *
261     * @param data
262     *           the metaschema data, or {@code null} if none
263     */
264    public Combine(IMetaschemaData data) {
265      this.__metaschemaData = data;
266    }
267
268    @Override
269    public IMetaschemaData getMetaschemaData() {
270      return __metaschemaData;
271    }
272
273    /**
274     * Get the "{@literal Combination Method}".
275     *
276     * <p>
277     * Declare how clashing controls should be handled.
278     *
279     * @return the method value, or {@code null} if not set
280     */
281    @Nullable
282    public String getMethod() {
283      return _method;
284    }
285
286    /**
287     * Set the "{@literal Combination Method}".
288     *
289     * <p>
290     * Declare how clashing controls should be handled.
291     *
292     * @param value
293     *           the method value to set, or {@code null} to clear
294     */
295    public void setMethod(@Nullable String value) {
296      _method = value;
297    }
298
299    @Override
300    public String toString() {
301      return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
302    }
303  }
304
305  /**
306   * Directs that controls appear without any grouping structure.
307   */
308  @MetaschemaAssembly(
309      formalName = "Flat Without Grouping",
310      description = "Directs that controls appear without any grouping structure.",
311      name = "flat",
312      moduleClass = OscalProfileModule.class
313  )
314  public static class Flat implements IBoundObject {
315    private final IMetaschemaData __metaschemaData;
316
317    /**
318     * Constructs a new {@code dev.metaschema.oscal.lib.model.Merge.Flat} instance with no metadata.
319     */
320    public Flat() {
321      this(null);
322    }
323
324    /**
325     * Constructs a new {@code dev.metaschema.oscal.lib.model.Merge.Flat} instance with the specified metadata.
326     *
327     * @param data
328     *           the metaschema data, or {@code null} if none
329     */
330    public Flat(IMetaschemaData data) {
331      this.__metaschemaData = data;
332    }
333
334    @Override
335    public IMetaschemaData getMetaschemaData() {
336      return __metaschemaData;
337    }
338
339    @Override
340    public String toString() {
341      return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
342    }
343  }
344
345  /**
346   * Provides an alternate grouping structure that selected controls will be placed in.
347   */
348  @MetaschemaAssembly(
349      formalName = "Custom Grouping",
350      description = "Provides an alternate grouping structure that selected controls will be placed in.",
351      name = "custom",
352      moduleClass = OscalProfileModule.class,
353      remarks = "The `custom` element represents a custom arrangement or organization of controls in the resolution of a catalog. This structuring directive gives the profile author the ability to define an entirely different organization of controls as compared to their source catalog(s)."
354  )
355  public static class Custom implements IBoundObject {
356    private final IMetaschemaData __metaschemaData;
357
358    /**
359     * A group of (selected) controls or of groups of controls.
360     */
361    @BoundAssembly(
362        formalName = "Control Group",
363        description = "A group of (selected) controls or of groups of controls.",
364        useName = "group",
365        maxOccurs = -1,
366        groupAs = @GroupAs(name = "groups", inJson = JsonGroupAsBehavior.LIST)
367    )
368    private List<ProfileGroup> _groups;
369
370    /**
371     * Specifies which controls to use in the containing context.
372     */
373    @BoundAssembly(
374        formalName = "Insert Controls",
375        description = "Specifies which controls to use in the containing context.",
376        useName = "insert-controls",
377        maxOccurs = -1,
378        groupAs = @GroupAs(name = "insert-controls", inJson = JsonGroupAsBehavior.LIST)
379    )
380    private List<InsertControls> _insertControls;
381
382    /**
383     * Constructs a new {@code dev.metaschema.oscal.lib.model.Merge.Custom} instance with no metadata.
384     */
385    public Custom() {
386      this(null);
387    }
388
389    /**
390     * Constructs a new {@code dev.metaschema.oscal.lib.model.Merge.Custom} instance with the specified metadata.
391     *
392     * @param data
393     *           the metaschema data, or {@code null} if none
394     */
395    public Custom(IMetaschemaData data) {
396      this.__metaschemaData = data;
397    }
398
399    @Override
400    public IMetaschemaData getMetaschemaData() {
401      return __metaschemaData;
402    }
403
404    /**
405     * Get the "{@literal Control Group}".
406     *
407     * <p>
408     * A group of (selected) controls or of groups of controls.
409     *
410     * @return the group value
411     */
412    @NonNull
413    public List<ProfileGroup> getGroups() {
414      if (_groups == null) {
415        _groups = new LinkedList<>();
416      }
417      return ObjectUtils.notNull(_groups);
418    }
419
420    /**
421     * Set the "{@literal Control Group}".
422     *
423     * <p>
424     * A group of (selected) controls or of groups of controls.
425     *
426     * @param value
427     *           the group value to set
428     */
429    public void setGroups(@NonNull List<ProfileGroup> value) {
430      _groups = value;
431    }
432
433    /**
434     * Add a new {@link ProfileGroup} item to the underlying collection.
435     * @param item the item to add
436     * @return {@code true}
437     */
438    public boolean addGroup(ProfileGroup item) {
439      ProfileGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
440      if (_groups == null) {
441        _groups = new LinkedList<>();
442      }
443      return _groups.add(value);
444    }
445
446    /**
447     * Remove the first matching {@link ProfileGroup} item from the underlying collection.
448     * @param item the item to remove
449     * @return {@code true} if the item was removed or {@code false} otherwise
450     */
451    public boolean removeGroup(ProfileGroup item) {
452      ProfileGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
453      return _groups != null && _groups.remove(value);
454    }
455
456    /**
457     * Get the "{@literal Insert Controls}".
458     *
459     * <p>
460     * Specifies which controls to use in the containing context.
461     *
462     * @return the insert-controls value
463     */
464    @NonNull
465    public List<InsertControls> getInsertControls() {
466      if (_insertControls == null) {
467        _insertControls = new LinkedList<>();
468      }
469      return ObjectUtils.notNull(_insertControls);
470    }
471
472    /**
473     * Set the "{@literal Insert Controls}".
474     *
475     * <p>
476     * Specifies which controls to use in the containing context.
477     *
478     * @param value
479     *           the insert-controls value to set
480     */
481    public void setInsertControls(@NonNull List<InsertControls> value) {
482      _insertControls = value;
483    }
484
485    /**
486     * Add a new {@link InsertControls} item to the underlying collection.
487     * @param item the item to add
488     * @return {@code true}
489     */
490    public boolean addInsertControls(InsertControls item) {
491      InsertControls value = ObjectUtils.requireNonNull(item,"item cannot be null");
492      if (_insertControls == null) {
493        _insertControls = new LinkedList<>();
494      }
495      return _insertControls.add(value);
496    }
497
498    /**
499     * Remove the first matching {@link InsertControls} item from the underlying collection.
500     * @param item the item to remove
501     * @return {@code true} if the item was removed or {@code false} otherwise
502     */
503    public boolean removeInsertControls(InsertControls item) {
504      InsertControls value = ObjectUtils.requireNonNull(item,"item cannot be null");
505      return _insertControls != null && _insertControls.remove(value);
506    }
507
508    @Override
509    public String toString() {
510      return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
511    }
512  }
513}