ComponentDefinition.java
package gov.nist.secauto.oscal.lib.model;
import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter;
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.AssemblyConstraints;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
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.Index;
import gov.nist.secauto.metaschema.databind.model.annotations.IsUnique;
import gov.nist.secauto.metaschema.databind.model.annotations.KeyField;
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 java.util.UUID;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* A collection of component descriptions, which may optionally be grouped by capability.
*/
@MetaschemaAssembly(
formalName = "Component Definition",
description = "A collection of component descriptions, which may optionally be grouped by capability.",
name = "component-definition",
moduleClass = OscalComponentDefinitionModule.class,
rootName = "component-definition",
modelConstraints = @AssemblyConstraints(index = @Index(level = IConstraint.Level.ERROR, target = "component", name = "index-system-component-uuid", keyFields = @KeyField(target = "@uuid"), remarks = "Since multiple `component` entries can be provided, each component must have a unique `uuid`."), unique = @IsUnique(id = "unique-component-definition-capability", level = IConstraint.Level.ERROR, target = "capability", keyFields = @KeyField(target = "@uuid"), remarks = "A given `component` must not be referenced more than once within the same `capability`."))
)
public class ComponentDefinition implements IBoundObject {
private final IMetaschemaData __metaschemaData;
/**
* "Provides a globally unique means to identify a given component definition instance."
*/
@BoundFlag(
formalName = "Component Definition Universally Unique Identifier",
description = "Provides a globally unique means to identify a given component definition instance.",
name = "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 = "Import Component Definition",
description = "Loads a component definition from another resource.",
useName = "import-component-definition",
maxOccurs = -1,
groupAs = @GroupAs(name = "import-component-definitions", inJson = JsonGroupAsBehavior.LIST)
)
private List<ImportComponentDefinition> _importComponentDefinitions;
@BoundAssembly(
formalName = "Component",
description = "A defined component that can be part of an implemented system.",
useName = "component",
maxOccurs = -1,
groupAs = @GroupAs(name = "components", inJson = JsonGroupAsBehavior.LIST)
)
private List<DefinedComponent> _components;
@BoundAssembly(
formalName = "Capability",
description = "A grouping of other components and/or capabilities.",
useName = "capability",
maxOccurs = -1,
groupAs = @GroupAs(name = "capabilities", inJson = JsonGroupAsBehavior.LIST)
)
private List<Capability> _capabilities;
@BoundAssembly(
formalName = "Back matter",
description = "A collection of resources that may be referenced from within the OSCAL document instance.",
useName = "back-matter"
)
private BackMatter _backMatter;
public ComponentDefinition() {
this(null);
}
public ComponentDefinition(IMetaschemaData data) {
this.__metaschemaData = data;
}
@Override
public IMetaschemaData getMetaschemaData() {
return __metaschemaData;
}
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<ImportComponentDefinition> getImportComponentDefinitions() {
return _importComponentDefinitions;
}
public void setImportComponentDefinitions(List<ImportComponentDefinition> value) {
_importComponentDefinitions = value;
}
/**
* Add a new {@link ImportComponentDefinition} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addImportComponentDefinition(ImportComponentDefinition item) {
ImportComponentDefinition value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_importComponentDefinitions == null) {
_importComponentDefinitions = new LinkedList<>();
}
return _importComponentDefinitions.add(value);
}
/**
* Remove the first matching {@link ImportComponentDefinition} 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 removeImportComponentDefinition(ImportComponentDefinition item) {
ImportComponentDefinition value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _importComponentDefinitions != null && _importComponentDefinitions.remove(value);
}
public List<DefinedComponent> getComponents() {
return _components;
}
public void setComponents(List<DefinedComponent> value) {
_components = value;
}
/**
* Add a new {@link DefinedComponent} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addComponent(DefinedComponent item) {
DefinedComponent value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_components == null) {
_components = new LinkedList<>();
}
return _components.add(value);
}
/**
* Remove the first matching {@link DefinedComponent} 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 removeComponent(DefinedComponent item) {
DefinedComponent value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _components != null && _components.remove(value);
}
public List<Capability> getCapabilities() {
return _capabilities;
}
public void setCapabilities(List<Capability> value) {
_capabilities = value;
}
/**
* Add a new {@link Capability} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addCapability(Capability item) {
Capability value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_capabilities == null) {
_capabilities = new LinkedList<>();
}
return _capabilities.add(value);
}
/**
* Remove the first matching {@link Capability} 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 removeCapability(Capability item) {
Capability value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _capabilities != null && _capabilities.remove(value);
}
public BackMatter getBackMatter() {
return _backMatter;
}
public void setBackMatter(BackMatter value) {
_backMatter = value;
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
}
}