ProfileSelectControlById.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.model.constraint.IConstraint;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
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 gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
import gov.nist.secauto.oscal.lib.model.control.profile.AbstractProfileSelectControlById;
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;
/**
* Select a control or controls from an imported control set.
*/
@MetaschemaAssembly(
formalName = "Select Control",
description = "Select a control or controls from an imported control set.",
name = "select-control-by-id",
moduleClass = OscalProfileModule.class,
remarks = "If `with-child-controls` is \"yes\" on the call to a control, no sibling `call`elements need to be used to call any controls appearing within it. Since generally, this is how control enhancements are represented (as controls within controls), this provides a way to include controls with all their dependent controls (enhancements) without having to call them individually."
)
public class ProfileSelectControlById extends AbstractProfileSelectControlById implements IBoundObject {
private final IMetaschemaData __metaschemaData;
/**
* "When a control is included, whether its child (dependent) controls are also included."
*/
@BoundFlag(
formalName = "Include Contained Controls with Control",
description = "When a control is included, whether its child (dependent) controls are also included.",
name = "with-child-controls",
typeAdapter = TokenAdapter.class,
valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "yes", description = "Include child controls with an included control."), @AllowedValue(value = "no", description = "When importing a control, only include child controls that are also explicitly called.")}))
)
private String _withChildControls;
@BoundField(
formalName = "Match Controls by Identifier",
description = "Selecting a control by its ID given as a literal.",
useName = "with-id",
maxOccurs = -1,
groupAs = @GroupAs(name = "with-ids", inJson = JsonGroupAsBehavior.LIST),
typeAdapter = TokenAdapter.class
)
private List<String> _withIds;
@BoundAssembly(
formalName = "Match Controls by Pattern",
description = "Selecting a set of controls by matching their IDs with a wildcard pattern.",
useName = "matching",
maxOccurs = -1,
groupAs = @GroupAs(name = "matching", inJson = JsonGroupAsBehavior.LIST)
)
private List<Matching> _matching;
public ProfileSelectControlById() {
this(null);
}
public ProfileSelectControlById(IMetaschemaData data) {
this.__metaschemaData = data;
}
@Override
public IMetaschemaData getMetaschemaData() {
return __metaschemaData;
}
public String getWithChildControls() {
return _withChildControls;
}
public void setWithChildControls(String value) {
_withChildControls = value;
}
public List<String> getWithIds() {
return _withIds;
}
public void setWithIds(List<String> value) {
_withIds = value;
}
/**
* Add a new {@link String} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addWithId(String item) {
String value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_withIds == null) {
_withIds = new LinkedList<>();
}
return _withIds.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 removeWithId(String item) {
String value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _withIds != null && _withIds.remove(value);
}
public List<Matching> getMatching() {
return _matching;
}
public void setMatching(List<Matching> value) {
_matching = value;
}
/**
* Add a new {@link Matching} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addMatching(Matching item) {
Matching value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_matching == null) {
_matching = new LinkedList<>();
}
return _matching.add(value);
}
/**
* Remove the first matching {@link Matching} 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 removeMatching(Matching item) {
Matching value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _matching != null && _matching.remove(value);
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
}
}