Catalog.java
package gov.nist.secauto.oscal.lib.model;
import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
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.Index;
import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import gov.nist.secauto.oscal.lib.model.control.catalog.AbstractCatalog;
import java.lang.Override;
import java.lang.String;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
/**
* A structured, <a href="https://pages.nist.gov/OSCAL/concepts/terminology/#catalog">organized collection</a> of control information.
*/
@MetaschemaAssembly(
formalName = "Catalog",
description = "A structured, [organized collection](https://pages.nist.gov/OSCAL/concepts/terminology/#catalog) of control information.",
name = "catalog",
metaschema = OscalCatalogMetaschema.class,
rootName = "catalog",
remarks = "Catalogs may use one or more `group` objects to subdivide the control contents of a catalog."
)
@ValueConstraints(
allowedValues = {
@AllowedValues(level = IConstraint.Level.ERROR, target = "metadata/prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@name", values = {@AllowedValue(value = "resolution-tool", description = "The tool used to produce a resolved profile."), @AllowedValue(value = "source-profile-uuid", description = "The document-level `uuid` of the source profile from which the catalog was produced by [profile resolution](https://pages.nist.gov/OSCAL/concepts/processing/profile-resolution/).")}),
@AllowedValues(level = IConstraint.Level.ERROR, target = "metadata/link/@rel", allowOthers = true, values = {@AllowedValue(value = "source-profile", description = "The profile from which the catalog was produced by [profile resolution](https://pages.nist.gov/OSCAL/concepts/processing/profile-resolution/)."), @AllowedValue(value = "source-profile-uuid", description = "The document-level `uuid` of the profile from which the catalog was produced by [profile resolution](https://pages.nist.gov/OSCAL/concepts/processing/profile-resolution/).")})
}
)
@AssemblyConstraints(
index = {
@Index(level = IConstraint.Level.ERROR, target = "//part", name = "catalog-parts", keyFields = @KeyField(target = "@id")),
@Index(level = IConstraint.Level.ERROR, target = "//prop", name = "catalog-props", keyFields = @KeyField(target = "@uuid")),
@Index(level = IConstraint.Level.ERROR, target = "//(control|group|part)", name = "catalog-groups-controls-parts", keyFields = @KeyField(target = "@id")),
@Index(level = IConstraint.Level.ERROR, target = "//control", name = "catalog-controls", keyFields = @KeyField(target = "@id")),
@Index(level = IConstraint.Level.ERROR, target = "//param", name = "catalog-params", keyFields = @KeyField(target = "@id")),
@Index(level = IConstraint.Level.ERROR, target = "//group", name = "catalog-groups", keyFields = @KeyField(target = "@id"))
}
)
public class Catalog extends AbstractCatalog {
@BoundFlag(
formalName = "Catalog Universally Unique Identifier",
description = "Provides a globally unique means to identify a given catalog instance.",
useName = "uuid",
required = true,
typeAdapter = UuidAdapter.class
)
private UUID _uuid;
@BoundAssembly(
formalName = "Document Metadata",
description = "Provides information about the containing document, and defines concepts that are shared across the document.",
useName = "metadata",
minOccurs = 1
)
private Metadata _metadata;
@BoundAssembly(
formalName = "Parameter",
description = "Parameters provide a mechanism for the dynamic assignment of value(s) in a control.",
useName = "param",
maxOccurs = -1
)
@GroupAs(
name = "params",
inJson = JsonGroupAsBehavior.LIST
)
private List<Parameter> _params;
@BoundAssembly(
formalName = "Control",
description = "A [structured object](https://pages.nist.gov/OSCAL/concepts/terminology/#control) representing a requirement or guideline, which when implemented will reduce an aspect of risk related to an information system and its information.",
useName = "control",
maxOccurs = -1
)
@GroupAs(
name = "controls",
inJson = JsonGroupAsBehavior.LIST
)
private List<Control> _controls;
@BoundAssembly(
formalName = "Control Group",
description = "A group of controls, or of groups of controls.",
useName = "group",
maxOccurs = -1
)
@GroupAs(
name = "groups",
inJson = JsonGroupAsBehavior.LIST
)
private List<CatalogGroup> _groups;
@BoundAssembly(
formalName = "Back matter",
description = "A collection of resources that may be referenced from within the OSCAL document instance.",
useName = "back-matter",
remarks = "Back matter including references and resources."
)
private BackMatter _backMatter;
public Catalog() {
}
public UUID getUuid() {
return _uuid;
}
public void setUuid(UUID value) {
_uuid = value;
}
public Metadata getMetadata() {
return _metadata;
}
public void setMetadata(Metadata value) {
_metadata = value;
}
public List<Parameter> getParams() {
return _params;
}
public void setParams(List<Parameter> value) {
_params = value;
}
/**
* Add a new {@link Parameter} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addParam(Parameter item) {
Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_params == null) {
_params = new LinkedList<>();
}
return _params.add(value);
}
/**
* Remove the first matching {@link Parameter} 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 removeParam(Parameter item) {
Parameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _params == null ? false : _params.remove(value);
}
public List<Control> getControls() {
return _controls;
}
public void setControls(List<Control> value) {
_controls = value;
}
/**
* Add a new {@link Control} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addControl(Control item) {
Control value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_controls == null) {
_controls = new LinkedList<>();
}
return _controls.add(value);
}
/**
* Remove the first matching {@link Control} 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 removeControl(Control item) {
Control value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _controls == null ? false : _controls.remove(value);
}
public List<CatalogGroup> getGroups() {
return _groups;
}
public void setGroups(List<CatalogGroup> value) {
_groups = value;
}
/**
* Add a new {@link CatalogGroup} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addGroup(CatalogGroup item) {
CatalogGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_groups == null) {
_groups = new LinkedList<>();
}
return _groups.add(value);
}
/**
* Remove the first matching {@link CatalogGroup} 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 removeGroup(CatalogGroup item) {
CatalogGroup value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _groups == null ? false : _groups.remove(value);
}
public BackMatter getBackMatter() {
return _backMatter;
}
public void setBackMatter(BackMatter value) {
_backMatter = value;
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
}
}