1 package gov.nist.secauto.oscal.lib.model;
2
3 import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
4 import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
5 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
6 import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
7 import gov.nist.secauto.metaschema.binding.model.annotations.Index;
8 import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique;
9 import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
10 import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
11 import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
12 import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
13 import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
14 import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
15 import java.lang.Override;
16 import java.lang.String;
17 import java.util.LinkedList;
18 import java.util.List;
19 import java.util.UUID;
20 import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
21 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
22
23
24
25
26 @MetaschemaAssembly(
27 formalName = "Component Definition",
28 description = "A collection of component descriptions, which may optionally be grouped by capability.",
29 name = "component-definition",
30 metaschema = OscalComponentDefinitionMetaschema.class,
31 rootName = "component-definition"
32 )
33 @AssemblyConstraints(
34 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`."),
35 isUnique = @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`.")
36 )
37 public class ComponentDefinition {
38 @BoundFlag(
39 formalName = "Component Definition Universally Unique Identifier",
40 description = "Provides a globally unique means to identify a given component definition instance.",
41 useName = "uuid",
42 required = true,
43 typeAdapter = UuidAdapter.class
44 )
45 private UUID _uuid;
46
47 @BoundAssembly(
48 formalName = "Document Metadata",
49 description = "Provides information about the containing document, and defines concepts that are shared across the document.",
50 useName = "metadata",
51 minOccurs = 1
52 )
53 private Metadata _metadata;
54
55 @BoundAssembly(
56 formalName = "Import Component Definition",
57 description = "Loads a component definition from another resource.",
58 useName = "import-component-definition",
59 maxOccurs = -1
60 )
61 @GroupAs(
62 name = "import-component-definitions",
63 inJson = JsonGroupAsBehavior.LIST
64 )
65 private List<ImportComponentDefinition> _importComponentDefinitions;
66
67 @BoundAssembly(
68 formalName = "Component",
69 description = "A defined component that can be part of an implemented system.",
70 useName = "component",
71 maxOccurs = -1
72 )
73 @GroupAs(
74 name = "components",
75 inJson = JsonGroupAsBehavior.LIST
76 )
77 private List<DefinedComponent> _components;
78
79 @BoundAssembly(
80 formalName = "Capability",
81 description = "A grouping of other components and/or capabilities.",
82 useName = "capability",
83 maxOccurs = -1
84 )
85 @GroupAs(
86 name = "capabilities",
87 inJson = JsonGroupAsBehavior.LIST
88 )
89 private List<Capability> _capabilities;
90
91 @BoundAssembly(
92 formalName = "Back matter",
93 description = "A collection of resources that may be referenced from within the OSCAL document instance.",
94 useName = "back-matter"
95 )
96 private BackMatter _backMatter;
97
98 public ComponentDefinition() {
99 }
100
101 public UUID getUuid() {
102 return _uuid;
103 }
104
105 public void setUuid(UUID value) {
106 _uuid = value;
107 }
108
109 public Metadata getMetadata() {
110 return _metadata;
111 }
112
113 public void setMetadata(Metadata value) {
114 _metadata = value;
115 }
116
117 public List<ImportComponentDefinition> getImportComponentDefinitions() {
118 return _importComponentDefinitions;
119 }
120
121 public void setImportComponentDefinitions(List<ImportComponentDefinition> value) {
122 _importComponentDefinitions = value;
123 }
124
125
126
127
128
129
130 public boolean addImportComponentDefinition(ImportComponentDefinition item) {
131 ImportComponentDefinition value = ObjectUtils.requireNonNull(item,"item cannot be null");
132 if (_importComponentDefinitions == null) {
133 _importComponentDefinitions = new LinkedList<>();
134 }
135 return _importComponentDefinitions.add(value);
136 }
137
138
139
140
141
142
143 public boolean removeImportComponentDefinition(ImportComponentDefinition item) {
144 ImportComponentDefinition value = ObjectUtils.requireNonNull(item,"item cannot be null");
145 return _importComponentDefinitions == null ? false : _importComponentDefinitions.remove(value);
146 }
147
148 public List<DefinedComponent> getComponents() {
149 return _components;
150 }
151
152 public void setComponents(List<DefinedComponent> value) {
153 _components = value;
154 }
155
156
157
158
159
160
161 public boolean addComponent(DefinedComponent item) {
162 DefinedComponent value = ObjectUtils.requireNonNull(item,"item cannot be null");
163 if (_components == null) {
164 _components = new LinkedList<>();
165 }
166 return _components.add(value);
167 }
168
169
170
171
172
173
174 public boolean removeComponent(DefinedComponent item) {
175 DefinedComponent value = ObjectUtils.requireNonNull(item,"item cannot be null");
176 return _components == null ? false : _components.remove(value);
177 }
178
179 public List<Capability> getCapabilities() {
180 return _capabilities;
181 }
182
183 public void setCapabilities(List<Capability> value) {
184 _capabilities = value;
185 }
186
187
188
189
190
191
192 public boolean addCapability(Capability item) {
193 Capability value = ObjectUtils.requireNonNull(item,"item cannot be null");
194 if (_capabilities == null) {
195 _capabilities = new LinkedList<>();
196 }
197 return _capabilities.add(value);
198 }
199
200
201
202
203
204
205 public boolean removeCapability(Capability item) {
206 Capability value = ObjectUtils.requireNonNull(item,"item cannot be null");
207 return _capabilities == null ? false : _capabilities.remove(value);
208 }
209
210 public BackMatter getBackMatter() {
211 return _backMatter;
212 }
213
214 public void setBackMatter(BackMatter value) {
215 _backMatter = value;
216 }
217
218 @Override
219 public String toString() {
220 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
221 }
222 }