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.TokenAdapter;
006import dev.metaschema.core.model.IBoundObject;
007import dev.metaschema.core.model.IMetaschemaData;
008import dev.metaschema.core.model.JsonGroupAsBehavior;
009import dev.metaschema.core.model.constraint.IConstraint;
010import dev.metaschema.core.util.ObjectUtils;
011import dev.metaschema.databind.model.annotations.AllowedValue;
012import dev.metaschema.databind.model.annotations.AllowedValues;
013import dev.metaschema.databind.model.annotations.BoundAssembly;
014import dev.metaschema.databind.model.annotations.BoundChoice;
015import dev.metaschema.databind.model.annotations.BoundFlag;
016import dev.metaschema.databind.model.annotations.GroupAs;
017import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
018import dev.metaschema.databind.model.annotations.ValueConstraints;
019import edu.umd.cs.findbugs.annotations.NonNull;
020import edu.umd.cs.findbugs.annotations.Nullable;
021import java.util.LinkedList;
022import java.util.List;
023import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
024import org.apache.commons.lang3.builder.ToStringStyle;
025
026/**
027 * Specifies which controls to use in the containing context.
028 */
029@MetaschemaAssembly(
030    formalName = "Insert Controls",
031    description = "Specifies which controls to use in the containing context.",
032    name = "insert-controls",
033    moduleClass = OscalProfileModule.class,
034    remarks = "To be schema-valid, this element must contain either (but not both) a single `include-all` directive, or a sequence of `include-controls` directives.\n"
035            + "\n"
036            + "If this directive is not provided, then no controls are to be inserted; i.e., all controls are included explicitly."
037)
038public class InsertControls implements IBoundObject {
039  private final IMetaschemaData __metaschemaData;
040
041  /**
042   * A designation of how a selection of controls in a profile is to be ordered.
043   */
044  @BoundFlag(
045      formalName = "Order",
046      description = "A designation of how a selection of controls in a profile is to be ordered.",
047      name = "order",
048      typeAdapter = TokenAdapter.class,
049      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(id = "oscal-profile-insert-controls-order-values", level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "keep", description = "Use the order of their appearance, using a depth-first traversal of the source profile's imports."), @AllowedValue(value = "ascending", description = "Sort all selected controls into ascending alphanumeric order by their ID."), @AllowedValue(value = "descending", description = "Sort all selected controls into descending alphanumeric order by their ID.")}))
050  )
051  private String _order;
052
053  /**
054   * Include all controls from the imported catalog or profile resources.
055   */
056  @BoundAssembly(
057      formalName = "Include All",
058      description = "Include all controls from the imported catalog or profile resources.",
059      useName = "include-all",
060      minOccurs = 1
061  )
062  @BoundChoice(
063      choiceId = "choice-1"
064  )
065  private IncludeAll _includeAll;
066
067  /**
068   * Select a control or controls from an imported control set.
069   */
070  @BoundAssembly(
071      formalName = "Select Control",
072      description = "Select a control or controls from an imported control set.",
073      useName = "include-controls",
074      minOccurs = 1,
075      maxOccurs = -1,
076      groupAs = @GroupAs(name = "include-controls", inJson = JsonGroupAsBehavior.LIST)
077  )
078  @BoundChoice(
079      choiceId = "choice-1"
080  )
081  private List<ProfileSelectControlById> _includeControls;
082
083  /**
084   * Select a control or controls from an imported control set.
085   */
086  @BoundAssembly(
087      formalName = "Select Control",
088      description = "Select a control or controls from an imported control set.",
089      useName = "exclude-controls",
090      remarks = "Identifies which controls to exclude, or eliminate, from the set of matching includes.",
091      maxOccurs = -1,
092      groupAs = @GroupAs(name = "exclude-controls", inJson = JsonGroupAsBehavior.LIST)
093  )
094  private List<ProfileSelectControlById> _excludeControls;
095
096  /**
097   * Constructs a new {@code dev.metaschema.oscal.lib.model.InsertControls} instance with no metadata.
098   */
099  public InsertControls() {
100    this(null);
101  }
102
103  /**
104   * Constructs a new {@code dev.metaschema.oscal.lib.model.InsertControls} instance with the specified metadata.
105   *
106   * @param data
107   *           the metaschema data, or {@code null} if none
108   */
109  public InsertControls(IMetaschemaData data) {
110    this.__metaschemaData = data;
111  }
112
113  @Override
114  public IMetaschemaData getMetaschemaData() {
115    return __metaschemaData;
116  }
117
118  /**
119   * Get the "{@literal Order}".
120   *
121   * <p>
122   * A designation of how a selection of controls in a profile is to be ordered.
123   *
124   * @return the order value, or {@code null} if not set
125   */
126  @Nullable
127  public String getOrder() {
128    return _order;
129  }
130
131  /**
132   * Set the "{@literal Order}".
133   *
134   * <p>
135   * A designation of how a selection of controls in a profile is to be ordered.
136   *
137   * @param value
138   *           the order value to set, or {@code null} to clear
139   */
140  public void setOrder(@Nullable String value) {
141    _order = value;
142  }
143
144  /**
145   * Get the "{@literal Include All}".
146   *
147   * <p>
148   * Include all controls from the imported catalog or profile resources.
149   *
150   * @return the include-all value, or {@code null} if not set
151   */
152  @Nullable
153  public IncludeAll getIncludeAll() {
154    return _includeAll;
155  }
156
157  /**
158   * Set the "{@literal Include All}".
159   *
160   * <p>
161   * Include all controls from the imported catalog or profile resources.
162   *
163   * @param value
164   *           the include-all value to set, or {@code null} to clear
165   */
166  public void setIncludeAll(@Nullable IncludeAll value) {
167    _includeAll = value;
168  }
169
170  /**
171   * Get the "{@literal Select Control}".
172   *
173   * <p>
174   * Select a control or controls from an imported control set.
175   *
176   * @return the include-controls value
177   */
178  @NonNull
179  public List<ProfileSelectControlById> getIncludeControls() {
180    if (_includeControls == null) {
181      _includeControls = new LinkedList<>();
182    }
183    return ObjectUtils.notNull(_includeControls);
184  }
185
186  /**
187   * Set the "{@literal Select Control}".
188   *
189   * <p>
190   * Select a control or controls from an imported control set.
191   *
192   * @param value
193   *           the include-controls value to set
194   */
195  public void setIncludeControls(@NonNull List<ProfileSelectControlById> value) {
196    _includeControls = value;
197  }
198
199  /**
200   * Add a new {@link ProfileSelectControlById} item to the underlying collection.
201   * @param item the item to add
202   * @return {@code true}
203   */
204  public boolean addIncludeControls(ProfileSelectControlById item) {
205    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
206    if (_includeControls == null) {
207      _includeControls = new LinkedList<>();
208    }
209    return _includeControls.add(value);
210  }
211
212  /**
213   * Remove the first matching {@link ProfileSelectControlById} item from the underlying collection.
214   * @param item the item to remove
215   * @return {@code true} if the item was removed or {@code false} otherwise
216   */
217  public boolean removeIncludeControls(ProfileSelectControlById item) {
218    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
219    return _includeControls != null && _includeControls.remove(value);
220  }
221
222  /**
223   * Get the "{@literal Select Control}".
224   *
225   * <p>
226   * Select a control or controls from an imported control set.
227   *
228   * @return the exclude-controls value
229   */
230  @NonNull
231  public List<ProfileSelectControlById> getExcludeControls() {
232    if (_excludeControls == null) {
233      _excludeControls = new LinkedList<>();
234    }
235    return ObjectUtils.notNull(_excludeControls);
236  }
237
238  /**
239   * Set the "{@literal Select Control}".
240   *
241   * <p>
242   * Select a control or controls from an imported control set.
243   *
244   * @param value
245   *           the exclude-controls value to set
246   */
247  public void setExcludeControls(@NonNull List<ProfileSelectControlById> value) {
248    _excludeControls = value;
249  }
250
251  /**
252   * Add a new {@link ProfileSelectControlById} item to the underlying collection.
253   * @param item the item to add
254   * @return {@code true}
255   */
256  public boolean addExcludeControls(ProfileSelectControlById item) {
257    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
258    if (_excludeControls == null) {
259      _excludeControls = new LinkedList<>();
260    }
261    return _excludeControls.add(value);
262  }
263
264  /**
265   * Remove the first matching {@link ProfileSelectControlById} item from the underlying collection.
266   * @param item the item to remove
267   * @return {@code true} if the item was removed or {@code false} otherwise
268   */
269  public boolean removeExcludeControls(ProfileSelectControlById item) {
270    ProfileSelectControlById value = ObjectUtils.requireNonNull(item,"item cannot be null");
271    return _excludeControls != null && _excludeControls.remove(value);
272  }
273
274  @Override
275  public String toString() {
276    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
277  }
278}