001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.Base64Adapter; 004import gov.nist.secauto.metaschema.core.datatype.adapter.DateTimeWithTZAdapter; 005import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter; 006import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter; 007import gov.nist.secauto.metaschema.core.datatype.adapter.UriReferenceAdapter; 008import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter; 009import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; 010import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter; 011import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; 012import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter; 013import gov.nist.secauto.metaschema.core.model.IBoundObject; 014import gov.nist.secauto.metaschema.core.model.IMetaschemaData; 015import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior; 016import gov.nist.secauto.metaschema.core.model.constraint.IConstraint; 017import gov.nist.secauto.metaschema.core.util.ObjectUtils; 018import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue; 019import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues; 020import gov.nist.secauto.metaschema.databind.model.annotations.AssemblyConstraints; 021import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly; 022import gov.nist.secauto.metaschema.databind.model.annotations.BoundField; 023import gov.nist.secauto.metaschema.databind.model.annotations.BoundFieldValue; 024import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 025import gov.nist.secauto.metaschema.databind.model.annotations.Expect; 026import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs; 027import gov.nist.secauto.metaschema.databind.model.annotations.HasCardinality; 028import gov.nist.secauto.metaschema.databind.model.annotations.Index; 029import gov.nist.secauto.metaschema.databind.model.annotations.IsUnique; 030import gov.nist.secauto.metaschema.databind.model.annotations.KeyField; 031import gov.nist.secauto.metaschema.databind.model.annotations.Matches; 032import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 033import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaField; 034import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints; 035import gov.nist.secauto.oscal.lib.model.metadata.AbstractBackMatter; 036import java.lang.Override; 037import java.lang.String; 038import java.net.URI; 039import java.nio.ByteBuffer; 040import java.util.LinkedList; 041import java.util.List; 042import java.util.UUID; 043import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 044import org.apache.commons.lang3.builder.ToStringStyle; 045 046/** 047 * A collection of resources that may be referenced from within the OSCAL document instance. 048 */ 049@MetaschemaAssembly( 050 formalName = "Back matter", 051 description = "A collection of resources that may be referenced from within the OSCAL document instance.", 052 name = "back-matter", 053 moduleClass = OscalMetadataModule.class, 054 remarks = "Provides a collection of identified `resource` objects that can be referenced by a `link` with a `rel` value of \"reference\" and an `href` value that is a fragment \"#\" followed by a reference to a reference's `uuid`. Other specialized link \"rel\" values also use this pattern when indicated in that context of use.", 055 modelConstraints = @AssemblyConstraints(index = @Index(level = IConstraint.Level.ERROR, target = "resource", name = "index-back-matter-resource", keyFields = @KeyField(target = "@uuid"))) 056) 057public class BackMatter extends AbstractBackMatter implements IBoundObject { 058 private final IMetaschemaData __metaschemaData; 059 060 @BoundAssembly( 061 formalName = "Resource", 062 description = "A resource associated with content in the containing document instance. A resource may be directly included in the document using base64 encoding or may point to one or more equivalent internet resources.", 063 useName = "resource", 064 remarks = "A resource can be used in two ways. 1) it may point to an specific retrievable network resource using a `rlink`, or 2) it may be included as an attachment using a `base64`. A resource may contain multiple `rlink` and `base64` entries that represent alternative download locations (rlink) and attachments (base64) for the same resource.\n" 065 + "\n" 066 + "Both rlink and base64 allow for a `media-type` to be specified, which is used to distinguish between different representations of the same resource (e.g., Microsoft Word, PDF). When multiple `rlink` and `base64` items are included for a given resource, all items must contain equivalent information. This allows the document consumer to choose a preferred item to process based on a the selected item's `media-type`. This is extremely important when the items represent OSCAL content that is represented in alternate formats (i.e., XML, JSON, YAML), allowing the same OSCAL data to be processed from any of the available formats indicated by the items.\n" 067 + "\n" 068 + "When a resource includes a citation, then the `title` and `citation` properties must both be included.", 069 maxOccurs = -1, 070 groupAs = @GroupAs(name = "resources", inJson = JsonGroupAsBehavior.LIST) 071 ) 072 private List<Resource> _resources; 073 074 public BackMatter() { 075 this(null); 076 } 077 078 public BackMatter(IMetaschemaData data) { 079 this.__metaschemaData = data; 080 } 081 082 @Override 083 public IMetaschemaData getMetaschemaData() { 084 return __metaschemaData; 085 } 086 087 public List<Resource> getResources() { 088 return _resources; 089 } 090 091 public void setResources(List<Resource> value) { 092 _resources = value; 093 } 094 095 /** 096 * Add a new {@link Resource} item to the underlying collection. 097 * @param item the item to add 098 * @return {@code true} 099 */ 100 public boolean addResource(Resource item) { 101 Resource value = ObjectUtils.requireNonNull(item,"item cannot be null"); 102 if (_resources == null) { 103 _resources = new LinkedList<>(); 104 } 105 return _resources.add(value); 106 } 107 108 /** 109 * Remove the first matching {@link Resource} item from the underlying collection. 110 * @param item the item to remove 111 * @return {@code true} if the item was removed or {@code false} otherwise 112 */ 113 public boolean removeResource(Resource item) { 114 Resource value = ObjectUtils.requireNonNull(item,"item cannot be null"); 115 return _resources != null && _resources.remove(value); 116 } 117 118 @Override 119 public String toString() { 120 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 121 } 122 123 /** 124 * A resource associated with content in the containing document instance. A resource may be directly included in the document using base64 encoding or may point to one or more equivalent internet resources. 125 */ 126 @MetaschemaAssembly( 127 formalName = "Resource", 128 description = "A resource associated with content in the containing document instance. A resource may be directly included in the document using base64 encoding or may point to one or more equivalent internet resources.", 129 name = "resource", 130 moduleClass = OscalMetadataModule.class, 131 remarks = "A resource can be used in two ways. 1) it may point to an specific retrievable network resource using a `rlink`, or 2) it may be included as an attachment using a `base64`. A resource may contain multiple `rlink` and `base64` entries that represent alternative download locations (rlink) and attachments (base64) for the same resource.\n" 132 + "\n" 133 + "Both rlink and base64 allow for a `media-type` to be specified, which is used to distinguish between different representations of the same resource (e.g., Microsoft Word, PDF). When multiple `rlink` and `base64` items are included for a given resource, all items must contain equivalent information. This allows the document consumer to choose a preferred item to process based on a the selected item's `media-type`. This is extremely important when the items represent OSCAL content that is represented in alternate formats (i.e., XML, JSON, YAML), allowing the same OSCAL data to be processed from any of the available formats indicated by the items.\n" 134 + "\n" 135 + "When a resource includes a citation, then the `title` and `citation` properties must both be included.", 136 valueConstraints = @ValueConstraints(allowedValues = {@AllowedValues(level = IConstraint.Level.ERROR, target = "prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@name", values = {@AllowedValue(value = "type", description = "Identifies the type of resource represented. The most specific appropriate type value SHOULD be used."), @AllowedValue(value = "version", description = "For resources representing a published document, this represents the version number of that document."), @AllowedValue(value = "published", description = "For resources representing a published document, this represents the publication date of that document.")}), @AllowedValues(level = IConstraint.Level.ERROR, target = "prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name='type']/@value", values = {@AllowedValue(value = "logo", description = "Indicates the resource is an organization's logo."), @AllowedValue(value = "image", description = "Indicates the resource represents an image."), @AllowedValue(value = "screen-shot", description = "Indicates the resource represents an image of screen content."), @AllowedValue(value = "law", description = "Indicates the resource represents an applicable law."), @AllowedValue(value = "regulation", description = "Indicates the resource represents an applicable regulation."), @AllowedValue(value = "standard", description = "Indicates the resource represents an applicable standard."), @AllowedValue(value = "external-guidance", description = "Indicates the resource represents applicable guidance."), @AllowedValue(value = "acronyms", description = "Indicates the resource provides a list of relevant acronyms."), @AllowedValue(value = "citation", description = "Indicates the resource cites relevant information."), @AllowedValue(value = "policy", description = "Indicates the resource is a policy."), @AllowedValue(value = "procedure", description = "Indicates the resource is a procedure."), @AllowedValue(value = "system-guide", description = "Indicates the resource is guidance document related to the subject system of an SSP."), @AllowedValue(value = "users-guide", description = "Indicates the resource is guidance document a user's guide or administrator's guide."), @AllowedValue(value = "administrators-guide", description = "Indicates the resource is guidance document a administrator's guide."), @AllowedValue(value = "rules-of-behavior", description = "Indicates the resource represents rules of behavior content."), @AllowedValue(value = "plan", description = "Indicates the resource represents a plan."), @AllowedValue(value = "artifact", description = "Indicates the resource represents an artifact, such as may be reviewed by an assessor."), @AllowedValue(value = "evidence", description = "Indicates the resource represents evidence, such as to support an assessment finding."), @AllowedValue(value = "tool-output", description = "Indicates the resource represents output from a tool."), @AllowedValue(value = "raw-data", description = "Indicates the resource represents machine data, which may require a tool or analysis for interpretation or presentation."), @AllowedValue(value = "interview-notes", description = "Indicates the resource represents notes from an interview, such as may be collected during an assessment."), @AllowedValue(value = "questionnaire", description = "Indicates the resource is a set of questions, possibly with responses."), @AllowedValue(value = "report", description = "Indicates the resource is a report."), @AllowedValue(value = "agreement", description = "Indicates the resource is a formal agreement between two or more parties.")})}, matches = @Matches(level = IConstraint.Level.ERROR, target = "prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name='published']/@value", typeAdapter = DateTimeWithTZAdapter.class), expect = @Expect(description = "A `title` is required when a `citation` is provided.", level = IConstraint.Level.ERROR, target = ".[citation]", test = "title")), 137 modelConstraints = @AssemblyConstraints(unique = {@IsUnique(id = "unique-resource-rlink-href", description = "Ensure that each rlink item references a unique resource.", level = IConstraint.Level.ERROR, target = "rlink", keyFields = {@KeyField(target = "@href"), @KeyField(target = "@media-type")}), @IsUnique(id = "unique-resource-base64-filename", description = "Ensure that all base64 resources have a unique `filename`.", level = IConstraint.Level.ERROR, target = "base64", keyFields = @KeyField(target = "@filename"))}, cardinality = @HasCardinality(description = "A resource should provide at least an `rlink` or `base64` object.", level = IConstraint.Level.WARNING, target = "rlink|base64", minOccurs = 1)) 138 ) 139 public static class Resource implements IBoundObject { 140 private final IMetaschemaData __metaschemaData; 141 142 /** 143 * "A unique identifier for a resource." 144 */ 145 @BoundFlag( 146 formalName = "Resource Universally Unique Identifier", 147 description = "A unique identifier for a resource.", 148 name = "uuid", 149 required = true, 150 typeAdapter = UuidAdapter.class 151 ) 152 private UUID _uuid; 153 154 @BoundField( 155 formalName = "Resource Title", 156 description = "An optional name given to the resource, which may be used by a tool for display and navigation.", 157 useName = "title", 158 typeAdapter = MarkupLineAdapter.class 159 ) 160 private MarkupLine _title; 161 162 @BoundField( 163 formalName = "Resource Description", 164 description = "An optional short summary of the resource used to indicate the purpose of the resource.", 165 useName = "description", 166 typeAdapter = MarkupMultilineAdapter.class 167 ) 168 private MarkupMultiline _description; 169 170 @BoundAssembly( 171 formalName = "Property", 172 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 173 useName = "prop", 174 maxOccurs = -1, 175 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 176 ) 177 private List<Property> _props; 178 179 @BoundField( 180 formalName = "Document Identifier", 181 description = "A document identifier qualified by an identifier `scheme`.", 182 useName = "document-id", 183 maxOccurs = -1, 184 groupAs = @GroupAs(name = "document-ids", inJson = JsonGroupAsBehavior.LIST) 185 ) 186 private List<DocumentId> _documentIds; 187 188 @BoundAssembly( 189 formalName = "Citation", 190 description = "An optional citation consisting of end note text using structured markup.", 191 useName = "citation" 192 ) 193 private Citation _citation; 194 195 @BoundAssembly( 196 formalName = "Resource link", 197 description = "A URL-based pointer to an external resource with an optional hash for verification and change detection.", 198 useName = "rlink", 199 remarks = "Multiple `rlink` objects can be included for a resource. In such a case, all provided `rlink` items are intended to be equivalent in content, but may differ in structure or format.\n" 200 + "\n" 201 + "A `media-type` is used to identify the format of a given rlink, and can be used to differentiate items in a collection of rlinks. The `media-type` provides a hint to the OSCAL document consumer about the structure of the resource referenced by the `rlink`.", 202 maxOccurs = -1, 203 groupAs = @GroupAs(name = "rlinks", inJson = JsonGroupAsBehavior.LIST) 204 ) 205 private List<Rlink> _rlinks; 206 207 @BoundField( 208 formalName = "Base64", 209 description = "A resource encoded using the Base64 alphabet defined by [RFC 2045](https://www.rfc-editor.org/rfc/rfc2045.html).", 210 useName = "base64" 211 ) 212 private Base64 _base64; 213 214 @BoundField( 215 formalName = "Remarks", 216 description = "Additional commentary about the containing object.", 217 useName = "remarks", 218 typeAdapter = MarkupMultilineAdapter.class 219 ) 220 private MarkupMultiline _remarks; 221 222 public Resource() { 223 this(null); 224 } 225 226 public Resource(IMetaschemaData data) { 227 this.__metaschemaData = data; 228 } 229 230 @Override 231 public IMetaschemaData getMetaschemaData() { 232 return __metaschemaData; 233 } 234 235 public UUID getUuid() { 236 return _uuid; 237 } 238 239 public void setUuid(UUID value) { 240 _uuid = value; 241 } 242 243 public MarkupLine getTitle() { 244 return _title; 245 } 246 247 public void setTitle(MarkupLine value) { 248 _title = value; 249 } 250 251 public MarkupMultiline getDescription() { 252 return _description; 253 } 254 255 public void setDescription(MarkupMultiline value) { 256 _description = value; 257 } 258 259 public List<Property> getProps() { 260 return _props; 261 } 262 263 public void setProps(List<Property> value) { 264 _props = value; 265 } 266 267 /** 268 * Add a new {@link Property} item to the underlying collection. 269 * @param item the item to add 270 * @return {@code true} 271 */ 272 public boolean addProp(Property item) { 273 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 274 if (_props == null) { 275 _props = new LinkedList<>(); 276 } 277 return _props.add(value); 278 } 279 280 /** 281 * Remove the first matching {@link Property} item from the underlying collection. 282 * @param item the item to remove 283 * @return {@code true} if the item was removed or {@code false} otherwise 284 */ 285 public boolean removeProp(Property item) { 286 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 287 return _props != null && _props.remove(value); 288 } 289 290 public List<DocumentId> getDocumentIds() { 291 return _documentIds; 292 } 293 294 public void setDocumentIds(List<DocumentId> value) { 295 _documentIds = value; 296 } 297 298 /** 299 * Add a new {@link DocumentId} item to the underlying collection. 300 * @param item the item to add 301 * @return {@code true} 302 */ 303 public boolean addDocumentId(DocumentId item) { 304 DocumentId value = ObjectUtils.requireNonNull(item,"item cannot be null"); 305 if (_documentIds == null) { 306 _documentIds = new LinkedList<>(); 307 } 308 return _documentIds.add(value); 309 } 310 311 /** 312 * Remove the first matching {@link DocumentId} item from the underlying collection. 313 * @param item the item to remove 314 * @return {@code true} if the item was removed or {@code false} otherwise 315 */ 316 public boolean removeDocumentId(DocumentId item) { 317 DocumentId value = ObjectUtils.requireNonNull(item,"item cannot be null"); 318 return _documentIds != null && _documentIds.remove(value); 319 } 320 321 public Citation getCitation() { 322 return _citation; 323 } 324 325 public void setCitation(Citation value) { 326 _citation = value; 327 } 328 329 public List<Rlink> getRlinks() { 330 return _rlinks; 331 } 332 333 public void setRlinks(List<Rlink> value) { 334 _rlinks = value; 335 } 336 337 /** 338 * Add a new {@link Rlink} item to the underlying collection. 339 * @param item the item to add 340 * @return {@code true} 341 */ 342 public boolean addRlink(Rlink item) { 343 Rlink value = ObjectUtils.requireNonNull(item,"item cannot be null"); 344 if (_rlinks == null) { 345 _rlinks = new LinkedList<>(); 346 } 347 return _rlinks.add(value); 348 } 349 350 /** 351 * Remove the first matching {@link Rlink} item from the underlying collection. 352 * @param item the item to remove 353 * @return {@code true} if the item was removed or {@code false} otherwise 354 */ 355 public boolean removeRlink(Rlink item) { 356 Rlink value = ObjectUtils.requireNonNull(item,"item cannot be null"); 357 return _rlinks != null && _rlinks.remove(value); 358 } 359 360 public Base64 getBase64() { 361 return _base64; 362 } 363 364 public void setBase64(Base64 value) { 365 _base64 = value; 366 } 367 368 public MarkupMultiline getRemarks() { 369 return _remarks; 370 } 371 372 public void setRemarks(MarkupMultiline value) { 373 _remarks = value; 374 } 375 376 @Override 377 public String toString() { 378 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 379 } 380 381 /** 382 * An optional citation consisting of end note text using structured markup. 383 */ 384 @MetaschemaAssembly( 385 formalName = "Citation", 386 description = "An optional citation consisting of end note text using structured markup.", 387 name = "citation", 388 moduleClass = OscalMetadataModule.class 389 ) 390 public static class Citation implements IBoundObject { 391 private final IMetaschemaData __metaschemaData; 392 393 @BoundField( 394 formalName = "Citation Text", 395 description = "A line of citation text.", 396 useName = "text", 397 minOccurs = 1, 398 typeAdapter = MarkupLineAdapter.class 399 ) 400 private MarkupLine _text; 401 402 @BoundAssembly( 403 formalName = "Property", 404 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 405 useName = "prop", 406 maxOccurs = -1, 407 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 408 ) 409 private List<Property> _props; 410 411 @BoundAssembly( 412 formalName = "Link", 413 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 414 useName = "link", 415 maxOccurs = -1, 416 groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST) 417 ) 418 private List<Link> _links; 419 420 public Citation() { 421 this(null); 422 } 423 424 public Citation(IMetaschemaData data) { 425 this.__metaschemaData = data; 426 } 427 428 @Override 429 public IMetaschemaData getMetaschemaData() { 430 return __metaschemaData; 431 } 432 433 public MarkupLine getText() { 434 return _text; 435 } 436 437 public void setText(MarkupLine value) { 438 _text = value; 439 } 440 441 public List<Property> getProps() { 442 return _props; 443 } 444 445 public void setProps(List<Property> value) { 446 _props = value; 447 } 448 449 /** 450 * Add a new {@link Property} item to the underlying collection. 451 * @param item the item to add 452 * @return {@code true} 453 */ 454 public boolean addProp(Property item) { 455 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 456 if (_props == null) { 457 _props = new LinkedList<>(); 458 } 459 return _props.add(value); 460 } 461 462 /** 463 * Remove the first matching {@link Property} item from the underlying collection. 464 * @param item the item to remove 465 * @return {@code true} if the item was removed or {@code false} otherwise 466 */ 467 public boolean removeProp(Property item) { 468 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 469 return _props != null && _props.remove(value); 470 } 471 472 public List<Link> getLinks() { 473 return _links; 474 } 475 476 public void setLinks(List<Link> value) { 477 _links = value; 478 } 479 480 /** 481 * Add a new {@link Link} item to the underlying collection. 482 * @param item the item to add 483 * @return {@code true} 484 */ 485 public boolean addLink(Link item) { 486 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 487 if (_links == null) { 488 _links = new LinkedList<>(); 489 } 490 return _links.add(value); 491 } 492 493 /** 494 * Remove the first matching {@link Link} item from the underlying collection. 495 * @param item the item to remove 496 * @return {@code true} if the item was removed or {@code false} otherwise 497 */ 498 public boolean removeLink(Link item) { 499 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 500 return _links != null && _links.remove(value); 501 } 502 503 @Override 504 public String toString() { 505 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 506 } 507 } 508 509 /** 510 * A URL-based pointer to an external resource with an optional hash for verification and change detection. 511 */ 512 @MetaschemaAssembly( 513 formalName = "Resource link", 514 description = "A URL-based pointer to an external resource with an optional hash for verification and change detection.", 515 name = "rlink", 516 moduleClass = OscalMetadataModule.class, 517 remarks = "Multiple `rlink` objects can be included for a resource. In such a case, all provided `rlink` items are intended to be equivalent in content, but may differ in structure or format.\n" 518 + "\n" 519 + "A `media-type` is used to identify the format of a given rlink, and can be used to differentiate items in a collection of rlinks. The `media-type` provides a hint to the OSCAL document consumer about the structure of the resource referenced by the `rlink`." 520 ) 521 public static class Rlink implements IBoundObject { 522 private final IMetaschemaData __metaschemaData; 523 524 /** 525 * "A resolvable URL pointing to the referenced resource." 526 */ 527 @BoundFlag( 528 formalName = "Hypertext Reference", 529 description = "A resolvable URL pointing to the referenced resource.", 530 name = "href", 531 required = true, 532 typeAdapter = UriReferenceAdapter.class, 533 remarks = "This value may be either:\n" 534 + "\n" 535 + "1. an [absolute URI](https://pages.nist.gov/OSCAL/concepts/uri-use/#absolute-uri) that points to a network resolvable resource,\n" 536 + "2. a [relative reference](https://pages.nist.gov/OSCAL/concepts/uri-use/#relative-reference) pointing to a network resolvable resource whose base URI is the URI of the containing document, or" 537 ) 538 private URI _href; 539 540 /** 541 * "A label that indicates the nature of a resource, as a data serialization or format." 542 */ 543 @BoundFlag( 544 formalName = "Media Type", 545 description = "A label that indicates the nature of a resource, as a data serialization or format.", 546 name = "media-type", 547 typeAdapter = StringAdapter.class 548 ) 549 private String _mediaType; 550 551 @BoundField( 552 formalName = "Hash", 553 description = "A hash of the resource identified by `href`, which can be used to verify the resource was not changed since it was hashed.", 554 useName = "hash", 555 remarks = "The `hash` value can be used to confirm that the resource referenced by the `href` is the same resources that was hashed by retrieving the resource, calculating a hash, and comparing the result to this value.", 556 maxOccurs = -1, 557 groupAs = @GroupAs(name = "hashes", inJson = JsonGroupAsBehavior.LIST) 558 ) 559 private List<Hash> _hashes; 560 561 public Rlink() { 562 this(null); 563 } 564 565 public Rlink(IMetaschemaData data) { 566 this.__metaschemaData = data; 567 } 568 569 @Override 570 public IMetaschemaData getMetaschemaData() { 571 return __metaschemaData; 572 } 573 574 public URI getHref() { 575 return _href; 576 } 577 578 public void setHref(URI value) { 579 _href = value; 580 } 581 582 public String getMediaType() { 583 return _mediaType; 584 } 585 586 public void setMediaType(String value) { 587 _mediaType = value; 588 } 589 590 public List<Hash> getHashes() { 591 return _hashes; 592 } 593 594 public void setHashes(List<Hash> value) { 595 _hashes = value; 596 } 597 598 /** 599 * Add a new {@link Hash} item to the underlying collection. 600 * @param item the item to add 601 * @return {@code true} 602 */ 603 public boolean addHash(Hash item) { 604 Hash value = ObjectUtils.requireNonNull(item,"item cannot be null"); 605 if (_hashes == null) { 606 _hashes = new LinkedList<>(); 607 } 608 return _hashes.add(value); 609 } 610 611 /** 612 * Remove the first matching {@link Hash} item from the underlying collection. 613 * @param item the item to remove 614 * @return {@code true} if the item was removed or {@code false} otherwise 615 */ 616 public boolean removeHash(Hash item) { 617 Hash value = ObjectUtils.requireNonNull(item,"item cannot be null"); 618 return _hashes != null && _hashes.remove(value); 619 } 620 621 @Override 622 public String toString() { 623 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 624 } 625 } 626 627 /** 628 * A resource encoded using the Base64 alphabet defined by <a href="https://www.rfc-editor.org/rfc/rfc2045.html">RFC 2045</a>. 629 */ 630 @MetaschemaField( 631 formalName = "Base64", 632 description = "A resource encoded using the Base64 alphabet defined by [RFC 2045](https://www.rfc-editor.org/rfc/rfc2045.html).", 633 name = "base64", 634 moduleClass = OscalMetadataModule.class 635 ) 636 public static class Base64 implements IBoundObject { 637 private final IMetaschemaData __metaschemaData; 638 639 /** 640 * "Name of the file before it was encoded as Base64 to be embedded in a <code>resource</code>. This is the name that will be assigned to the file when the file is decoded." 641 */ 642 @BoundFlag( 643 formalName = "File Name", 644 description = "Name of the file before it was encoded as Base64 to be embedded in a `resource`. This is the name that will be assigned to the file when the file is decoded.", 645 name = "filename", 646 typeAdapter = TokenAdapter.class 647 ) 648 private String _filename; 649 650 /** 651 * "A label that indicates the nature of a resource, as a data serialization or format." 652 */ 653 @BoundFlag( 654 formalName = "Media Type", 655 description = "A label that indicates the nature of a resource, as a data serialization or format.", 656 name = "media-type", 657 typeAdapter = StringAdapter.class 658 ) 659 private String _mediaType; 660 661 @BoundFieldValue( 662 valueKeyName = "value", 663 typeAdapter = Base64Adapter.class 664 ) 665 private ByteBuffer _value; 666 667 public Base64() { 668 this(null); 669 } 670 671 public Base64(IMetaschemaData data) { 672 this.__metaschemaData = data; 673 } 674 675 @Override 676 public IMetaschemaData getMetaschemaData() { 677 return __metaschemaData; 678 } 679 680 public String getFilename() { 681 return _filename; 682 } 683 684 public void setFilename(String value) { 685 _filename = value; 686 } 687 688 public String getMediaType() { 689 return _mediaType; 690 } 691 692 public void setMediaType(String value) { 693 _mediaType = value; 694 } 695 696 public ByteBuffer getValue() { 697 return _value; 698 } 699 700 public void setValue(ByteBuffer value) { 701 _value = value; 702 } 703 704 @Override 705 public String toString() { 706 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 707 } 708 } 709 } 710}