ParameterConstraint.java
package gov.nist.secauto.oscal.lib.model;
import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline;
import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter;
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.BoundAssembly;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
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;
/**
* A formal or informal expression of a constraint or test.
*/
@MetaschemaAssembly(
formalName = "Constraint",
description = "A formal or informal expression of a constraint or test.",
name = "parameter-constraint",
moduleClass = OscalControlCommonModule.class
)
public class ParameterConstraint implements IBoundObject {
private final IMetaschemaData __metaschemaData;
@BoundField(
formalName = "Constraint Description",
description = "A textual summary of the constraint to be applied.",
useName = "description",
typeAdapter = MarkupMultilineAdapter.class
)
private MarkupMultiline _description;
@BoundAssembly(
formalName = "Constraint Test",
description = "A test expression which is expected to be evaluated by a tool.",
useName = "test",
maxOccurs = -1,
groupAs = @GroupAs(name = "tests", inJson = JsonGroupAsBehavior.LIST)
)
private List<Test> _tests;
public ParameterConstraint() {
this(null);
}
public ParameterConstraint(IMetaschemaData data) {
this.__metaschemaData = data;
}
@Override
public IMetaschemaData getMetaschemaData() {
return __metaschemaData;
}
public MarkupMultiline getDescription() {
return _description;
}
public void setDescription(MarkupMultiline value) {
_description = value;
}
public List<Test> getTests() {
return _tests;
}
public void setTests(List<Test> value) {
_tests = value;
}
/**
* Add a new {@link Test} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addTest(Test item) {
Test value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_tests == null) {
_tests = new LinkedList<>();
}
return _tests.add(value);
}
/**
* Remove the first matching {@link Test} 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 removeTest(Test item) {
Test value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _tests != null && _tests.remove(value);
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
}
/**
* A test expression which is expected to be evaluated by a tool.
*/
@MetaschemaAssembly(
formalName = "Constraint Test",
description = "A test expression which is expected to be evaluated by a tool.",
name = "test",
moduleClass = OscalControlCommonModule.class
)
public static class Test implements IBoundObject {
private final IMetaschemaData __metaschemaData;
@BoundField(
formalName = "Constraint test",
description = "A formal (executable) expression of a constraint.",
useName = "expression",
minOccurs = 1
)
private String _expression;
@BoundField(
formalName = "Remarks",
description = "Additional commentary about the containing object.",
useName = "remarks",
typeAdapter = MarkupMultilineAdapter.class
)
private MarkupMultiline _remarks;
public Test() {
this(null);
}
public Test(IMetaschemaData data) {
this.__metaschemaData = data;
}
@Override
public IMetaschemaData getMetaschemaData() {
return __metaschemaData;
}
public String getExpression() {
return _expression;
}
public void setExpression(String value) {
_expression = value;
}
public MarkupMultiline getRemarks() {
return _remarks;
}
public void setRemarks(MarkupMultiline value) {
_remarks = value;
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
}
}
}