001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_component_metaschema.xml 002// Do not edit - changes will be lost when regenerated. 003package dev.metaschema.oscal.lib.model; 004 005import dev.metaschema.core.datatype.adapter.UuidAdapter; 006import dev.metaschema.core.model.IBoundObject; 007import dev.metaschema.core.model.IMetaschemaData; 008import dev.metaschema.core.model.JsonGroupAsBehavior; 009import dev.metaschema.core.model.constraint.IConstraint; 010import dev.metaschema.core.util.ObjectUtils; 011import dev.metaschema.databind.model.annotations.AssemblyConstraints; 012import dev.metaschema.databind.model.annotations.BoundAssembly; 013import dev.metaschema.databind.model.annotations.BoundFlag; 014import dev.metaschema.databind.model.annotations.GroupAs; 015import dev.metaschema.databind.model.annotations.Index; 016import dev.metaschema.databind.model.annotations.IsUnique; 017import dev.metaschema.databind.model.annotations.KeyField; 018import dev.metaschema.databind.model.annotations.Let; 019import dev.metaschema.databind.model.annotations.MetaschemaAssembly; 020import dev.metaschema.databind.model.annotations.ValueConstraints; 021import edu.umd.cs.findbugs.annotations.NonNull; 022import edu.umd.cs.findbugs.annotations.Nullable; 023import java.util.LinkedList; 024import java.util.List; 025import java.util.UUID; 026import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 027import org.apache.commons.lang3.builder.ToStringStyle; 028 029/** 030 * A collection of component descriptions, which may optionally be grouped by capability. 031 */ 032@MetaschemaAssembly( 033 formalName = "Component Definition", 034 description = "A collection of component descriptions, which may optionally be grouped by capability.", 035 name = "component-definition", 036 moduleClass = OscalComponentDefinitionModule.class, 037 rootName = "component-definition", 038 valueConstraints = @ValueConstraints(lets = @Let(name = "all-imports", target = "import-component-definition ! recurse-depth('doc(resolve-uri(Q{http://csrc.nist.gov/ns/oscal/1.0}resolve-reference(@href)))/component-definition')")), 039 modelConstraints = @AssemblyConstraints(index = {@Index(id = "oscal-index-system-component-uuid", 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`."), @Index(id = "oscal-component-definition-index-metadata-scoped-role-id", formalName = "In-Scope Role Identifiers", description = "An index of role identifiers that are in-scope for the component-definition model. Roles are collected from imported component-definition. For a given role @id, a locally declared role takes precedence over a role that is imported, the role that was last imported.", level = IConstraint.Level.ERROR, target = "map:merge($all-imports/metadata/role ! map:entry(@id,.))?*", name = "index-imports-metadata-role-id", keyFields = @KeyField(target = "@id")), @Index(id = "oscal-component-definition-index-metadata-scoped-location-uuid", level = IConstraint.Level.ERROR, target = "map:merge($all-imports/metadata/location ! map:entry(@uuid,.))?*", name = "index-imports-metadata-location-uuid", keyFields = @KeyField(target = "@uuid")), @Index(id = "oscal-component-definition-index-metadata-scoped-party-uuid", level = IConstraint.Level.ERROR, target = "map:merge($all-imports/metadata/party ! map:entry(@uuid,.))?*", name = "index-imports-metadata-party-uuid", keyFields = @KeyField(target = "@uuid")), @Index(id = "oscal-component-definition-index-metadata-scoped-party-organization-uuid", level = IConstraint.Level.ERROR, target = "map:merge($all-imports/metadata/party[@type='organization'] ! map:entry(@uuid,.))?*", name = "index-imports-metadata-party-organization-uuid", keyFields = @KeyField(target = "@uuid")), @Index(id = "oscal-component-definition-index-metadata-scoped-property-uuid", level = IConstraint.Level.ERROR, target = "map:merge($all-imports//prop[@uuid] ! map:entry(@uuid,.))?*", name = "index-imports-metadata-property-uuid", keyFields = @KeyField(target = "@uuid"))}, unique = {@IsUnique(id = "oscal-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`."), @IsUnique(id = "oscal-unique-document-id", formalName = "Unique Document Identifier", description = "Ensure all document identifiers have a unique combination of @scheme and value.", level = IConstraint.Level.ERROR, target = "document-id", keyFields = {@KeyField(target = "@scheme"), @KeyField}), @IsUnique(id = "oscal-unique-property-in-context-location", formalName = "Unique Properties", description = "Ensure all properties are unique for a given location using a unique combination of @ns, @name, @class. @group. and @value.", level = IConstraint.Level.ERROR, target = ".//prop", keyFields = {@KeyField(target = "path(..)"), @KeyField(target = "@name"), @KeyField(target = "@ns"), @KeyField(target = "@class"), @KeyField(target = "@group"), @KeyField(target = "@value")}), @IsUnique(id = "oscal-unique-link-in-context-location", formalName = "Unique Links", description = "Ensure all links are unique for a given location using a unique combination of @href, @rel, and @media-type.", level = IConstraint.Level.ERROR, target = ".//link", keyFields = {@KeyField(target = "path(..)"), @KeyField(target = "@href"), @KeyField(target = "@rel"), @KeyField(target = "@media-type"), @KeyField(target = "@resource-fragment")}), @IsUnique(id = "oscal-unique-responsibility-in-context-location", formalName = "Unique Responsibilities", description = "Ensure all responsible-roles and responsible-parties are unique for a given location using a unique combination of @role-id and the combination of @party-uuid values.", level = IConstraint.Level.ERROR, target = ".//(responsible-party|responsible-role)", keyFields = {@KeyField(target = "path(..)"), @KeyField(target = "@role-id"), @KeyField(target = "@party-uuid")}, remarks = "Since `responsible-party` and `responsible-role` associate multiple `party-uuid` entries with a single `role-id`, each role-id must be referenced only once.")}) 040) 041public class ComponentDefinition extends AbstractOscalInstance implements IBoundObject { 042 private final IMetaschemaData __metaschemaData; 043 044 /** 045 * Provides a globally unique means to identify a given component definition instance. 046 */ 047 @BoundFlag( 048 formalName = "Component Definition Universally Unique Identifier", 049 description = "Provides a globally unique means to identify a given component definition instance.", 050 name = "uuid", 051 required = true, 052 typeAdapter = UuidAdapter.class 053 ) 054 private UUID _uuid; 055 056 /** 057 * Provides information about the containing document, and defines concepts that are shared across the document. 058 */ 059 @BoundAssembly( 060 formalName = "Document Metadata", 061 description = "Provides information about the containing document, and defines concepts that are shared across the document.", 062 useName = "metadata", 063 minOccurs = 1 064 ) 065 private Metadata _metadata; 066 067 /** 068 * Loads a component definition from another resource. 069 */ 070 @BoundAssembly( 071 formalName = "Import Component Definition", 072 description = "Loads a component definition from another resource.", 073 useName = "import-component-definition", 074 maxOccurs = -1, 075 groupAs = @GroupAs(name = "import-component-definitions", inJson = JsonGroupAsBehavior.LIST) 076 ) 077 private List<ImportComponentDefinition> _importComponentDefinitions; 078 079 /** 080 * A defined component that can be part of an implemented system. 081 */ 082 @BoundAssembly( 083 formalName = "Component", 084 description = "A defined component that can be part of an implemented system.", 085 useName = "component", 086 maxOccurs = -1, 087 groupAs = @GroupAs(name = "components", inJson = JsonGroupAsBehavior.LIST) 088 ) 089 private List<DefinedComponent> _components; 090 091 /** 092 * A grouping of other components and/or capabilities. 093 */ 094 @BoundAssembly( 095 formalName = "Capability", 096 description = "A grouping of other components and/or capabilities.", 097 useName = "capability", 098 maxOccurs = -1, 099 groupAs = @GroupAs(name = "capabilities", inJson = JsonGroupAsBehavior.LIST) 100 ) 101 private List<Capability> _capabilities; 102 103 /** 104 * A collection of resources that may be referenced from within the OSCAL document instance. 105 */ 106 @BoundAssembly( 107 formalName = "Back matter", 108 description = "A collection of resources that may be referenced from within the OSCAL document instance.", 109 useName = "back-matter" 110 ) 111 private BackMatter _backMatter; 112 113 /** 114 * Constructs a new {@code dev.metaschema.oscal.lib.model.ComponentDefinition} instance with no metadata. 115 */ 116 public ComponentDefinition() { 117 this(null); 118 } 119 120 /** 121 * Constructs a new {@code dev.metaschema.oscal.lib.model.ComponentDefinition} instance with the specified metadata. 122 * 123 * @param data 124 * the metaschema data, or {@code null} if none 125 */ 126 public ComponentDefinition(IMetaschemaData data) { 127 this.__metaschemaData = data; 128 } 129 130 @Override 131 public IMetaschemaData getMetaschemaData() { 132 return __metaschemaData; 133 } 134 135 /** 136 * Get the "{@literal Component Definition Universally Unique Identifier}". 137 * 138 * <p> 139 * Provides a globally unique means to identify a given component definition instance. 140 * 141 * @return the uuid value 142 */ 143 @NonNull 144 public UUID getUuid() { 145 return _uuid; 146 } 147 148 /** 149 * Set the "{@literal Component Definition Universally Unique Identifier}". 150 * 151 * <p> 152 * Provides a globally unique means to identify a given component definition instance. 153 * 154 * @param value 155 * the uuid value to set 156 */ 157 public void setUuid(@NonNull UUID value) { 158 _uuid = value; 159 } 160 161 /** 162 * Get the "{@literal Document Metadata}". 163 * 164 * <p> 165 * Provides information about the containing document, and defines concepts that are shared across the document. 166 * 167 * @return the metadata value 168 */ 169 @NonNull 170 public Metadata getMetadata() { 171 return _metadata; 172 } 173 174 /** 175 * Set the "{@literal Document Metadata}". 176 * 177 * <p> 178 * Provides information about the containing document, and defines concepts that are shared across the document. 179 * 180 * @param value 181 * the metadata value to set 182 */ 183 public void setMetadata(@NonNull Metadata value) { 184 _metadata = value; 185 } 186 187 /** 188 * Get the "{@literal Import Component Definition}". 189 * 190 * <p> 191 * Loads a component definition from another resource. 192 * 193 * @return the import-component-definition value 194 */ 195 @NonNull 196 public List<ImportComponentDefinition> getImportComponentDefinitions() { 197 if (_importComponentDefinitions == null) { 198 _importComponentDefinitions = new LinkedList<>(); 199 } 200 return ObjectUtils.notNull(_importComponentDefinitions); 201 } 202 203 /** 204 * Set the "{@literal Import Component Definition}". 205 * 206 * <p> 207 * Loads a component definition from another resource. 208 * 209 * @param value 210 * the import-component-definition value to set 211 */ 212 public void setImportComponentDefinitions(@NonNull List<ImportComponentDefinition> value) { 213 _importComponentDefinitions = value; 214 } 215 216 /** 217 * Add a new {@link ImportComponentDefinition} item to the underlying collection. 218 * @param item the item to add 219 * @return {@code true} 220 */ 221 public boolean addImportComponentDefinition(ImportComponentDefinition item) { 222 ImportComponentDefinition value = ObjectUtils.requireNonNull(item,"item cannot be null"); 223 if (_importComponentDefinitions == null) { 224 _importComponentDefinitions = new LinkedList<>(); 225 } 226 return _importComponentDefinitions.add(value); 227 } 228 229 /** 230 * Remove the first matching {@link ImportComponentDefinition} item from the underlying collection. 231 * @param item the item to remove 232 * @return {@code true} if the item was removed or {@code false} otherwise 233 */ 234 public boolean removeImportComponentDefinition(ImportComponentDefinition item) { 235 ImportComponentDefinition value = ObjectUtils.requireNonNull(item,"item cannot be null"); 236 return _importComponentDefinitions != null && _importComponentDefinitions.remove(value); 237 } 238 239 /** 240 * Get the "{@literal Component}". 241 * 242 * <p> 243 * A defined component that can be part of an implemented system. 244 * 245 * @return the component value 246 */ 247 @NonNull 248 public List<DefinedComponent> getComponents() { 249 if (_components == null) { 250 _components = new LinkedList<>(); 251 } 252 return ObjectUtils.notNull(_components); 253 } 254 255 /** 256 * Set the "{@literal Component}". 257 * 258 * <p> 259 * A defined component that can be part of an implemented system. 260 * 261 * @param value 262 * the component value to set 263 */ 264 public void setComponents(@NonNull List<DefinedComponent> value) { 265 _components = value; 266 } 267 268 /** 269 * Add a new {@link DefinedComponent} item to the underlying collection. 270 * @param item the item to add 271 * @return {@code true} 272 */ 273 public boolean addComponent(DefinedComponent item) { 274 DefinedComponent value = ObjectUtils.requireNonNull(item,"item cannot be null"); 275 if (_components == null) { 276 _components = new LinkedList<>(); 277 } 278 return _components.add(value); 279 } 280 281 /** 282 * Remove the first matching {@link DefinedComponent} item from the underlying collection. 283 * @param item the item to remove 284 * @return {@code true} if the item was removed or {@code false} otherwise 285 */ 286 public boolean removeComponent(DefinedComponent item) { 287 DefinedComponent value = ObjectUtils.requireNonNull(item,"item cannot be null"); 288 return _components != null && _components.remove(value); 289 } 290 291 /** 292 * Get the "{@literal Capability}". 293 * 294 * <p> 295 * A grouping of other components and/or capabilities. 296 * 297 * @return the capability value 298 */ 299 @NonNull 300 public List<Capability> getCapabilities() { 301 if (_capabilities == null) { 302 _capabilities = new LinkedList<>(); 303 } 304 return ObjectUtils.notNull(_capabilities); 305 } 306 307 /** 308 * Set the "{@literal Capability}". 309 * 310 * <p> 311 * A grouping of other components and/or capabilities. 312 * 313 * @param value 314 * the capability value to set 315 */ 316 public void setCapabilities(@NonNull List<Capability> value) { 317 _capabilities = value; 318 } 319 320 /** 321 * Add a new {@link Capability} item to the underlying collection. 322 * @param item the item to add 323 * @return {@code true} 324 */ 325 public boolean addCapability(Capability item) { 326 Capability value = ObjectUtils.requireNonNull(item,"item cannot be null"); 327 if (_capabilities == null) { 328 _capabilities = new LinkedList<>(); 329 } 330 return _capabilities.add(value); 331 } 332 333 /** 334 * Remove the first matching {@link Capability} item from the underlying collection. 335 * @param item the item to remove 336 * @return {@code true} if the item was removed or {@code false} otherwise 337 */ 338 public boolean removeCapability(Capability item) { 339 Capability value = ObjectUtils.requireNonNull(item,"item cannot be null"); 340 return _capabilities != null && _capabilities.remove(value); 341 } 342 343 /** 344 * Get the "{@literal Back matter}". 345 * 346 * <p> 347 * A collection of resources that may be referenced from within the OSCAL document instance. 348 * 349 * @return the back-matter value, or {@code null} if not set 350 */ 351 @Nullable 352 public BackMatter getBackMatter() { 353 return _backMatter; 354 } 355 356 /** 357 * Set the "{@literal Back matter}". 358 * 359 * <p> 360 * A collection of resources that may be referenced from within the OSCAL document instance. 361 * 362 * @param value 363 * the back-matter value to set, or {@code null} to clear 364 */ 365 public void setBackMatter(@Nullable BackMatter value) { 366 _backMatter = value; 367 } 368 369 @Override 370 public String toString() { 371 return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString()); 372 } 373}