001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_assessment-common_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.util.ObjectUtils;
010import dev.metaschema.databind.model.annotations.BoundField;
011import dev.metaschema.databind.model.annotations.BoundFlag;
012import dev.metaschema.databind.model.annotations.GroupAs;
013import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
014import edu.umd.cs.findbugs.annotations.NonNull;
015import java.util.LinkedList;
016import java.util.List;
017import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
018import org.apache.commons.lang3.builder.ToStringStyle;
019
020/**
021 * Used to select a control for inclusion/exclusion based on one or more control identifiers. A set of statement identifiers can be used to target the inclusion/exclusion to only specific control statements providing more granularity over the specific statements that are within the assessment scope.
022 */
023@MetaschemaAssembly(
024    formalName = "Select Control",
025    description = "Used to select a control for inclusion/exclusion based on one or more control identifiers. A set of statement identifiers can be used to target the inclusion/exclusion to only specific control statements providing more granularity over the specific statements that are within the assessment scope.",
026    name = "select-control-by-id",
027    moduleClass = OscalAssessmentCommonModule.class
028)
029public class SelectControlByIdOscalAssessmentCommon implements IBoundObject {
030  private final IMetaschemaData __metaschemaData;
031
032  /**
033   * A reference to a control with a corresponding <code>id</code> value. When referencing an externally defined <code>control</code>, the <code>Control Identifier Reference</code> must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).
034   */
035  @BoundFlag(
036      formalName = "Control Identifier Reference",
037      description = "A reference to a control with a corresponding `id` value. When referencing an externally defined `control`, the `Control Identifier Reference` must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).",
038      name = "control-id",
039      required = true,
040      typeAdapter = TokenAdapter.class
041  )
042  private String _controlId;
043
044  /**
045   * Used to constrain the selection to only specificity identified statements.
046   */
047  @BoundField(
048      formalName = "Include Specific Statements",
049      description = "Used to constrain the selection to only specificity identified statements.",
050      useName = "statement-id",
051      maxOccurs = -1,
052      groupAs = @GroupAs(name = "statement-ids", inJson = JsonGroupAsBehavior.LIST),
053      typeAdapter = TokenAdapter.class
054  )
055  private List<String> _statementIds;
056
057  /**
058   * Constructs a new {@code dev.metaschema.oscal.lib.model.SelectControlByIdOscalAssessmentCommon} instance with no metadata.
059   */
060  public SelectControlByIdOscalAssessmentCommon() {
061    this(null);
062  }
063
064  /**
065   * Constructs a new {@code dev.metaschema.oscal.lib.model.SelectControlByIdOscalAssessmentCommon} instance with the specified metadata.
066   *
067   * @param data
068   *           the metaschema data, or {@code null} if none
069   */
070  public SelectControlByIdOscalAssessmentCommon(IMetaschemaData data) {
071    this.__metaschemaData = data;
072  }
073
074  @Override
075  public IMetaschemaData getMetaschemaData() {
076    return __metaschemaData;
077  }
078
079  /**
080   * Get the "{@literal Control Identifier Reference}".
081   *
082   * <p>
083   * A reference to a control with a corresponding <code>id</code> value. When referencing an externally defined <code>control</code>, the <code>Control Identifier Reference</code> must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).
084   *
085   * @return the control-id value
086   */
087  @NonNull
088  public String getControlId() {
089    return _controlId;
090  }
091
092  /**
093   * Set the "{@literal Control Identifier Reference}".
094   *
095   * <p>
096   * A reference to a control with a corresponding <code>id</code> value. When referencing an externally defined <code>control</code>, the <code>Control Identifier Reference</code> must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).
097   *
098   * @param value
099   *           the control-id value to set
100   */
101  public void setControlId(@NonNull String value) {
102    _controlId = value;
103  }
104
105  /**
106   * Get the "{@literal Include Specific Statements}".
107   *
108   * <p>
109   * Used to constrain the selection to only specificity identified statements.
110   *
111   * @return the statement-id value
112   */
113  @NonNull
114  public List<String> getStatementIds() {
115    if (_statementIds == null) {
116      _statementIds = new LinkedList<>();
117    }
118    return ObjectUtils.notNull(_statementIds);
119  }
120
121  /**
122   * Set the "{@literal Include Specific Statements}".
123   *
124   * <p>
125   * Used to constrain the selection to only specificity identified statements.
126   *
127   * @param value
128   *           the statement-id value to set
129   */
130  public void setStatementIds(@NonNull List<String> value) {
131    _statementIds = value;
132  }
133
134  /**
135   * Add a new {@link String} item to the underlying collection.
136   * @param item the item to add
137   * @return {@code true}
138   */
139  public boolean addStatementId(String item) {
140    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
141    if (_statementIds == null) {
142      _statementIds = new LinkedList<>();
143    }
144    return _statementIds.add(value);
145  }
146
147  /**
148   * Remove the first matching {@link String} item from the underlying collection.
149   * @param item the item to remove
150   * @return {@code true} if the item was removed or {@code false} otherwise
151   */
152  public boolean removeStatementId(String item) {
153    String value = ObjectUtils.requireNonNull(item,"item cannot be null");
154    return _statementIds != null && _statementIds.remove(value);
155  }
156
157  @Override
158  public String toString() {
159    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
160  }
161}