SelectControlById.java
package gov.nist.secauto.oscal.lib.model;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import java.lang.Override;
import java.lang.String;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
/**
* 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 asessment scope.
*/
@MetaschemaAssembly(
formalName = "Select Control",
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 asessment scope.",
name = "select-control-by-id",
metaschema = OscalAssessmentCommonMetaschema.class
)
public class SelectControlById {
@BoundFlag(
formalName = "Control Identifier Reference",
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).",
useName = "control-id",
required = true,
typeAdapter = TokenAdapter.class
)
private String _controlId;
/**
* "Used to constrain the selection to only specificity identified statements."
*/
@BoundField(
formalName = "Include Specific Statements",
description = "Used to constrain the selection to only specificity identified statements.",
useName = "statement-id",
maxOccurs = -1
)
@BoundFieldValue(
typeAdapter = TokenAdapter.class
)
@GroupAs(
name = "statement-ids",
inJson = JsonGroupAsBehavior.LIST
)
private List<String> _statementIds;
public SelectControlById() {
}
public String getControlId() {
return _controlId;
}
public void setControlId(String value) {
_controlId = value;
}
public List<String> getStatementIds() {
return _statementIds;
}
public void setStatementIds(List<String> value) {
_statementIds = value;
}
/**
* Add a new {@link String} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addStatementId(String item) {
String value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_statementIds == null) {
_statementIds = new LinkedList<>();
}
return _statementIds.add(value);
}
/**
* Remove the first matching {@link String} item from the underlying collection.
* @param item the item to remove
* @return {@code true} if the item was removed or {@code false} otherwise
*/
public boolean removeStatementId(String item) {
String value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _statementIds == null ? false : _statementIds.remove(value);
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
}
}