ParameterSelection.java
package gov.nist.secauto.oscal.lib.model;
import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine;
import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter;
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.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 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;
/**
* Presenting a choice among alternatives.
*/
@MetaschemaAssembly(
formalName = "Selection",
description = "Presenting a choice among alternatives.",
name = "parameter-selection",
moduleClass = OscalControlCommonModule.class,
remarks = "A set of parameter value choices, that may be picked from to set the parameter value."
)
public class ParameterSelection implements IBoundObject {
private final IMetaschemaData __metaschemaData;
/**
* "Describes the number of selections that must occur. Without this setting, only one value should be assumed to be permitted."
*/
@BoundFlag(
formalName = "Parameter Cardinality",
description = "Describes the number of selections that must occur. Without this setting, only one value should be assumed to be permitted.",
name = "how-many",
typeAdapter = TokenAdapter.class,
valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "one", description = "Only one value is permitted."), @AllowedValue(value = "one-or-more", description = "One or more values are permitted.")}))
)
private String _howMany;
@BoundField(
formalName = "Choice",
description = "A value selection among several such options.",
useName = "choice",
maxOccurs = -1,
groupAs = @GroupAs(name = "choice", inJson = JsonGroupAsBehavior.LIST),
typeAdapter = MarkupLineAdapter.class
)
private List<MarkupLine> _choice;
public ParameterSelection() {
this(null);
}
public ParameterSelection(IMetaschemaData data) {
this.__metaschemaData = data;
}
@Override
public IMetaschemaData getMetaschemaData() {
return __metaschemaData;
}
public String getHowMany() {
return _howMany;
}
public void setHowMany(String value) {
_howMany = value;
}
public List<MarkupLine> getChoice() {
return _choice;
}
public void setChoice(List<MarkupLine> value) {
_choice = value;
}
/**
* Add a new {@link MarkupLine} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addChoice(MarkupLine item) {
MarkupLine value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_choice == null) {
_choice = new LinkedList<>();
}
return _choice.add(value);
}
/**
* Remove the first matching {@link MarkupLine} 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 removeChoice(MarkupLine item) {
MarkupLine value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _choice != null && _choice.remove(value);
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
}
}