SelectControlById.java
package gov.nist.secauto.oscal.lib.model;
import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
import gov.nist.secauto.metaschema.core.model.IBoundObject;
import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
import java.lang.Override;
import java.lang.String;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 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",
moduleClass = OscalAssessmentCommonModule.class
)
public class SelectControlById implements IBoundObject {
private final IMetaschemaData __metaschemaData;
/**
* "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)."
*/
@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).",
name = "control-id",
required = true,
typeAdapter = TokenAdapter.class
)
private String _controlId;
@BoundField(
formalName = "Include Specific Statements",
description = "Used to constrain the selection to only specificity identified statements.",
useName = "statement-id",
maxOccurs = -1,
groupAs = @GroupAs(name = "statement-ids", inJson = JsonGroupAsBehavior.LIST),
typeAdapter = TokenAdapter.class
)
private List<String> _statementIds;
public SelectControlById() {
this(null);
}
public SelectControlById(IMetaschemaData data) {
this.__metaschemaData = data;
}
@Override
public IMetaschemaData getMetaschemaData() {
return __metaschemaData;
}
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 && _statementIds.remove(value);
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
}
}