001package org.hl7.fhir.instance.model; 002 003/* 004 Copyright (c) 2011+, HL7, Inc. 005 All rights reserved. 006 007 Redistribution and use in source and binary forms, with or without modification, 008 are permitted provided that the following conditions are met: 009 010 * Redistributions of source code must retain the above copyright notice, this 011 list of conditions and the following disclaimer. 012 * Redistributions in binary form must reproduce the above copyright notice, 013 this list of conditions and the following disclaimer in the documentation 014 and/or other materials provided with the distribution. 015 * Neither the name of HL7 nor the names of its contributors may be used to 016 endorse or promote products derived from this software without specific 017 prior written permission. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 022 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 024 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 026 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 028 POSSIBILITY OF SUCH DAMAGE. 029 030*/ 031 032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 033import java.util.Date; 034import java.util.List; 035 036import org.hl7.fhir.exceptions.FHIRException; 037import org.hl7.fhir.instance.model.api.ICompositeType; 038import org.hl7.fhir.utilities.Utilities; 039 040import ca.uhn.fhir.model.api.annotation.*; 041/** 042 * For referring to data content defined in other formats. 043 */ 044@DatatypeDef(name="Attachment") 045public class Attachment extends Type implements ICompositeType { 046 047 /** 048 * Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate. 049 */ 050 @Child(name = "contentType", type = {CodeType.class}, order=0, min=0, max=1, modifier=false, summary=true) 051 @Description(shortDefinition="Mime type of the content, with charset etc.", formalDefinition="Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate." ) 052 protected CodeType contentType; 053 054 /** 055 * The human language of the content. The value can be any valid value according to BCP 47. 056 */ 057 @Child(name = "language", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true) 058 @Description(shortDefinition="Human language of the content (BCP-47)", formalDefinition="The human language of the content. The value can be any valid value according to BCP 47." ) 059 protected CodeType language; 060 061 /** 062 * The actual data of the attachment - a sequence of bytes. In XML, represented using base64. 063 */ 064 @Child(name = "data", type = {Base64BinaryType.class}, order=2, min=0, max=1, modifier=false, summary=true) 065 @Description(shortDefinition="Data inline, base64ed", formalDefinition="The actual data of the attachment - a sequence of bytes. In XML, represented using base64." ) 066 protected Base64BinaryType data; 067 068 /** 069 * An alternative location where the data can be accessed. 070 */ 071 @Child(name = "url", type = {UriType.class}, order=3, min=0, max=1, modifier=false, summary=true) 072 @Description(shortDefinition="Uri where the data can be found", formalDefinition="An alternative location where the data can be accessed." ) 073 protected UriType url; 074 075 /** 076 * The number of bytes of data that make up this attachment. 077 */ 078 @Child(name = "size", type = {UnsignedIntType.class}, order=4, min=0, max=1, modifier=false, summary=true) 079 @Description(shortDefinition="Number of bytes of content (if url provided)", formalDefinition="The number of bytes of data that make up this attachment." ) 080 protected UnsignedIntType size; 081 082 /** 083 * The calculated hash of the data using SHA-1. Represented using base64. 084 */ 085 @Child(name = "hash", type = {Base64BinaryType.class}, order=5, min=0, max=1, modifier=false, summary=true) 086 @Description(shortDefinition="Hash of the data (sha-1, base64ed)", formalDefinition="The calculated hash of the data using SHA-1. Represented using base64." ) 087 protected Base64BinaryType hash; 088 089 /** 090 * A label or set of text to display in place of the data. 091 */ 092 @Child(name = "title", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true) 093 @Description(shortDefinition="Label to display in place of the data", formalDefinition="A label or set of text to display in place of the data." ) 094 protected StringType title; 095 096 /** 097 * The date that the attachment was first created. 098 */ 099 @Child(name = "creation", type = {DateTimeType.class}, order=7, min=0, max=1, modifier=false, summary=true) 100 @Description(shortDefinition="Date attachment was first created", formalDefinition="The date that the attachment was first created." ) 101 protected DateTimeType creation; 102 103 private static final long serialVersionUID = 581007080L; 104 105 /* 106 * Constructor 107 */ 108 public Attachment() { 109 super(); 110 } 111 112 /** 113 * @return {@link #contentType} (Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value 114 */ 115 public CodeType getContentTypeElement() { 116 if (this.contentType == null) 117 if (Configuration.errorOnAutoCreate()) 118 throw new Error("Attempt to auto-create Attachment.contentType"); 119 else if (Configuration.doAutoCreate()) 120 this.contentType = new CodeType(); // bb 121 return this.contentType; 122 } 123 124 public boolean hasContentTypeElement() { 125 return this.contentType != null && !this.contentType.isEmpty(); 126 } 127 128 public boolean hasContentType() { 129 return this.contentType != null && !this.contentType.isEmpty(); 130 } 131 132 /** 133 * @param value {@link #contentType} (Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value 134 */ 135 public Attachment setContentTypeElement(CodeType value) { 136 this.contentType = value; 137 return this; 138 } 139 140 /** 141 * @return Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate. 142 */ 143 public String getContentType() { 144 return this.contentType == null ? null : this.contentType.getValue(); 145 } 146 147 /** 148 * @param value Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate. 149 */ 150 public Attachment setContentType(String value) { 151 if (Utilities.noString(value)) 152 this.contentType = null; 153 else { 154 if (this.contentType == null) 155 this.contentType = new CodeType(); 156 this.contentType.setValue(value); 157 } 158 return this; 159 } 160 161 /** 162 * @return {@link #language} (The human language of the content. The value can be any valid value according to BCP 47.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value 163 */ 164 public CodeType getLanguageElement() { 165 if (this.language == null) 166 if (Configuration.errorOnAutoCreate()) 167 throw new Error("Attempt to auto-create Attachment.language"); 168 else if (Configuration.doAutoCreate()) 169 this.language = new CodeType(); // bb 170 return this.language; 171 } 172 173 public boolean hasLanguageElement() { 174 return this.language != null && !this.language.isEmpty(); 175 } 176 177 public boolean hasLanguage() { 178 return this.language != null && !this.language.isEmpty(); 179 } 180 181 /** 182 * @param value {@link #language} (The human language of the content. The value can be any valid value according to BCP 47.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value 183 */ 184 public Attachment setLanguageElement(CodeType value) { 185 this.language = value; 186 return this; 187 } 188 189 /** 190 * @return The human language of the content. The value can be any valid value according to BCP 47. 191 */ 192 public String getLanguage() { 193 return this.language == null ? null : this.language.getValue(); 194 } 195 196 /** 197 * @param value The human language of the content. The value can be any valid value according to BCP 47. 198 */ 199 public Attachment setLanguage(String value) { 200 if (Utilities.noString(value)) 201 this.language = null; 202 else { 203 if (this.language == null) 204 this.language = new CodeType(); 205 this.language.setValue(value); 206 } 207 return this; 208 } 209 210 /** 211 * @return {@link #data} (The actual data of the attachment - a sequence of bytes. In XML, represented using base64.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value 212 */ 213 public Base64BinaryType getDataElement() { 214 if (this.data == null) 215 if (Configuration.errorOnAutoCreate()) 216 throw new Error("Attempt to auto-create Attachment.data"); 217 else if (Configuration.doAutoCreate()) 218 this.data = new Base64BinaryType(); // bb 219 return this.data; 220 } 221 222 public boolean hasDataElement() { 223 return this.data != null && !this.data.isEmpty(); 224 } 225 226 public boolean hasData() { 227 return this.data != null && !this.data.isEmpty(); 228 } 229 230 /** 231 * @param value {@link #data} (The actual data of the attachment - a sequence of bytes. In XML, represented using base64.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value 232 */ 233 public Attachment setDataElement(Base64BinaryType value) { 234 this.data = value; 235 return this; 236 } 237 238 /** 239 * @return The actual data of the attachment - a sequence of bytes. In XML, represented using base64. 240 */ 241 public byte[] getData() { 242 return this.data == null ? null : this.data.getValue(); 243 } 244 245 /** 246 * @param value The actual data of the attachment - a sequence of bytes. In XML, represented using base64. 247 */ 248 public Attachment setData(byte[] value) { 249 if (value == null) 250 this.data = null; 251 else { 252 if (this.data == null) 253 this.data = new Base64BinaryType(); 254 this.data.setValue(value); 255 } 256 return this; 257 } 258 259 /** 260 * @return {@link #url} (An alternative location where the data can be accessed.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value 261 */ 262 public UriType getUrlElement() { 263 if (this.url == null) 264 if (Configuration.errorOnAutoCreate()) 265 throw new Error("Attempt to auto-create Attachment.url"); 266 else if (Configuration.doAutoCreate()) 267 this.url = new UriType(); // bb 268 return this.url; 269 } 270 271 public boolean hasUrlElement() { 272 return this.url != null && !this.url.isEmpty(); 273 } 274 275 public boolean hasUrl() { 276 return this.url != null && !this.url.isEmpty(); 277 } 278 279 /** 280 * @param value {@link #url} (An alternative location where the data can be accessed.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value 281 */ 282 public Attachment setUrlElement(UriType value) { 283 this.url = value; 284 return this; 285 } 286 287 /** 288 * @return An alternative location where the data can be accessed. 289 */ 290 public String getUrl() { 291 return this.url == null ? null : this.url.getValue(); 292 } 293 294 /** 295 * @param value An alternative location where the data can be accessed. 296 */ 297 public Attachment setUrl(String value) { 298 if (Utilities.noString(value)) 299 this.url = null; 300 else { 301 if (this.url == null) 302 this.url = new UriType(); 303 this.url.setValue(value); 304 } 305 return this; 306 } 307 308 /** 309 * @return {@link #size} (The number of bytes of data that make up this attachment.). This is the underlying object with id, value and extensions. The accessor "getSize" gives direct access to the value 310 */ 311 public UnsignedIntType getSizeElement() { 312 if (this.size == null) 313 if (Configuration.errorOnAutoCreate()) 314 throw new Error("Attempt to auto-create Attachment.size"); 315 else if (Configuration.doAutoCreate()) 316 this.size = new UnsignedIntType(); // bb 317 return this.size; 318 } 319 320 public boolean hasSizeElement() { 321 return this.size != null && !this.size.isEmpty(); 322 } 323 324 public boolean hasSize() { 325 return this.size != null && !this.size.isEmpty(); 326 } 327 328 /** 329 * @param value {@link #size} (The number of bytes of data that make up this attachment.). This is the underlying object with id, value and extensions. The accessor "getSize" gives direct access to the value 330 */ 331 public Attachment setSizeElement(UnsignedIntType value) { 332 this.size = value; 333 return this; 334 } 335 336 /** 337 * @return The number of bytes of data that make up this attachment. 338 */ 339 public int getSize() { 340 return this.size == null || this.size.isEmpty() ? 0 : this.size.getValue(); 341 } 342 343 /** 344 * @param value The number of bytes of data that make up this attachment. 345 */ 346 public Attachment setSize(int value) { 347 if (this.size == null) 348 this.size = new UnsignedIntType(); 349 this.size.setValue(value); 350 return this; 351 } 352 353 /** 354 * @return {@link #hash} (The calculated hash of the data using SHA-1. Represented using base64.). This is the underlying object with id, value and extensions. The accessor "getHash" gives direct access to the value 355 */ 356 public Base64BinaryType getHashElement() { 357 if (this.hash == null) 358 if (Configuration.errorOnAutoCreate()) 359 throw new Error("Attempt to auto-create Attachment.hash"); 360 else if (Configuration.doAutoCreate()) 361 this.hash = new Base64BinaryType(); // bb 362 return this.hash; 363 } 364 365 public boolean hasHashElement() { 366 return this.hash != null && !this.hash.isEmpty(); 367 } 368 369 public boolean hasHash() { 370 return this.hash != null && !this.hash.isEmpty(); 371 } 372 373 /** 374 * @param value {@link #hash} (The calculated hash of the data using SHA-1. Represented using base64.). This is the underlying object with id, value and extensions. The accessor "getHash" gives direct access to the value 375 */ 376 public Attachment setHashElement(Base64BinaryType value) { 377 this.hash = value; 378 return this; 379 } 380 381 /** 382 * @return The calculated hash of the data using SHA-1. Represented using base64. 383 */ 384 public byte[] getHash() { 385 return this.hash == null ? null : this.hash.getValue(); 386 } 387 388 /** 389 * @param value The calculated hash of the data using SHA-1. Represented using base64. 390 */ 391 public Attachment setHash(byte[] value) { 392 if (value == null) 393 this.hash = null; 394 else { 395 if (this.hash == null) 396 this.hash = new Base64BinaryType(); 397 this.hash.setValue(value); 398 } 399 return this; 400 } 401 402 /** 403 * @return {@link #title} (A label or set of text to display in place of the data.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value 404 */ 405 public StringType getTitleElement() { 406 if (this.title == null) 407 if (Configuration.errorOnAutoCreate()) 408 throw new Error("Attempt to auto-create Attachment.title"); 409 else if (Configuration.doAutoCreate()) 410 this.title = new StringType(); // bb 411 return this.title; 412 } 413 414 public boolean hasTitleElement() { 415 return this.title != null && !this.title.isEmpty(); 416 } 417 418 public boolean hasTitle() { 419 return this.title != null && !this.title.isEmpty(); 420 } 421 422 /** 423 * @param value {@link #title} (A label or set of text to display in place of the data.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value 424 */ 425 public Attachment setTitleElement(StringType value) { 426 this.title = value; 427 return this; 428 } 429 430 /** 431 * @return A label or set of text to display in place of the data. 432 */ 433 public String getTitle() { 434 return this.title == null ? null : this.title.getValue(); 435 } 436 437 /** 438 * @param value A label or set of text to display in place of the data. 439 */ 440 public Attachment setTitle(String value) { 441 if (Utilities.noString(value)) 442 this.title = null; 443 else { 444 if (this.title == null) 445 this.title = new StringType(); 446 this.title.setValue(value); 447 } 448 return this; 449 } 450 451 /** 452 * @return {@link #creation} (The date that the attachment was first created.). This is the underlying object with id, value and extensions. The accessor "getCreation" gives direct access to the value 453 */ 454 public DateTimeType getCreationElement() { 455 if (this.creation == null) 456 if (Configuration.errorOnAutoCreate()) 457 throw new Error("Attempt to auto-create Attachment.creation"); 458 else if (Configuration.doAutoCreate()) 459 this.creation = new DateTimeType(); // bb 460 return this.creation; 461 } 462 463 public boolean hasCreationElement() { 464 return this.creation != null && !this.creation.isEmpty(); 465 } 466 467 public boolean hasCreation() { 468 return this.creation != null && !this.creation.isEmpty(); 469 } 470 471 /** 472 * @param value {@link #creation} (The date that the attachment was first created.). This is the underlying object with id, value and extensions. The accessor "getCreation" gives direct access to the value 473 */ 474 public Attachment setCreationElement(DateTimeType value) { 475 this.creation = value; 476 return this; 477 } 478 479 /** 480 * @return The date that the attachment was first created. 481 */ 482 public Date getCreation() { 483 return this.creation == null ? null : this.creation.getValue(); 484 } 485 486 /** 487 * @param value The date that the attachment was first created. 488 */ 489 public Attachment setCreation(Date value) { 490 if (value == null) 491 this.creation = null; 492 else { 493 if (this.creation == null) 494 this.creation = new DateTimeType(); 495 this.creation.setValue(value); 496 } 497 return this; 498 } 499 500 protected void listChildren(List<Property> childrenList) { 501 super.listChildren(childrenList); 502 childrenList.add(new Property("contentType", "code", "Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.", 0, java.lang.Integer.MAX_VALUE, contentType)); 503 childrenList.add(new Property("language", "code", "The human language of the content. The value can be any valid value according to BCP 47.", 0, java.lang.Integer.MAX_VALUE, language)); 504 childrenList.add(new Property("data", "base64Binary", "The actual data of the attachment - a sequence of bytes. In XML, represented using base64.", 0, java.lang.Integer.MAX_VALUE, data)); 505 childrenList.add(new Property("url", "uri", "An alternative location where the data can be accessed.", 0, java.lang.Integer.MAX_VALUE, url)); 506 childrenList.add(new Property("size", "unsignedInt", "The number of bytes of data that make up this attachment.", 0, java.lang.Integer.MAX_VALUE, size)); 507 childrenList.add(new Property("hash", "base64Binary", "The calculated hash of the data using SHA-1. Represented using base64.", 0, java.lang.Integer.MAX_VALUE, hash)); 508 childrenList.add(new Property("title", "string", "A label or set of text to display in place of the data.", 0, java.lang.Integer.MAX_VALUE, title)); 509 childrenList.add(new Property("creation", "dateTime", "The date that the attachment was first created.", 0, java.lang.Integer.MAX_VALUE, creation)); 510 } 511 512 @Override 513 public void setProperty(String name, Base value) throws FHIRException { 514 if (name.equals("contentType")) 515 this.contentType = castToCode(value); // CodeType 516 else if (name.equals("language")) 517 this.language = castToCode(value); // CodeType 518 else if (name.equals("data")) 519 this.data = castToBase64Binary(value); // Base64BinaryType 520 else if (name.equals("url")) 521 this.url = castToUri(value); // UriType 522 else if (name.equals("size")) 523 this.size = castToUnsignedInt(value); // UnsignedIntType 524 else if (name.equals("hash")) 525 this.hash = castToBase64Binary(value); // Base64BinaryType 526 else if (name.equals("title")) 527 this.title = castToString(value); // StringType 528 else if (name.equals("creation")) 529 this.creation = castToDateTime(value); // DateTimeType 530 else 531 super.setProperty(name, value); 532 } 533 534 @Override 535 public Base addChild(String name) throws FHIRException { 536 if (name.equals("contentType")) { 537 throw new FHIRException("Cannot call addChild on a primitive type Attachment.contentType"); 538 } 539 else if (name.equals("language")) { 540 throw new FHIRException("Cannot call addChild on a primitive type Attachment.language"); 541 } 542 else if (name.equals("data")) { 543 throw new FHIRException("Cannot call addChild on a primitive type Attachment.data"); 544 } 545 else if (name.equals("url")) { 546 throw new FHIRException("Cannot call addChild on a primitive type Attachment.url"); 547 } 548 else if (name.equals("size")) { 549 throw new FHIRException("Cannot call addChild on a primitive type Attachment.size"); 550 } 551 else if (name.equals("hash")) { 552 throw new FHIRException("Cannot call addChild on a primitive type Attachment.hash"); 553 } 554 else if (name.equals("title")) { 555 throw new FHIRException("Cannot call addChild on a primitive type Attachment.title"); 556 } 557 else if (name.equals("creation")) { 558 throw new FHIRException("Cannot call addChild on a primitive type Attachment.creation"); 559 } 560 else 561 return super.addChild(name); 562 } 563 564 public String fhirType() { 565 return "Attachment"; 566 567 } 568 569 public Attachment copy() { 570 Attachment dst = new Attachment(); 571 copyValues(dst); 572 dst.contentType = contentType == null ? null : contentType.copy(); 573 dst.language = language == null ? null : language.copy(); 574 dst.data = data == null ? null : data.copy(); 575 dst.url = url == null ? null : url.copy(); 576 dst.size = size == null ? null : size.copy(); 577 dst.hash = hash == null ? null : hash.copy(); 578 dst.title = title == null ? null : title.copy(); 579 dst.creation = creation == null ? null : creation.copy(); 580 return dst; 581 } 582 583 protected Attachment typedCopy() { 584 return copy(); 585 } 586 587 @Override 588 public boolean equalsDeep(Base other) { 589 if (!super.equalsDeep(other)) 590 return false; 591 if (!(other instanceof Attachment)) 592 return false; 593 Attachment o = (Attachment) other; 594 return compareDeep(contentType, o.contentType, true) && compareDeep(language, o.language, true) 595 && compareDeep(data, o.data, true) && compareDeep(url, o.url, true) && compareDeep(size, o.size, true) 596 && compareDeep(hash, o.hash, true) && compareDeep(title, o.title, true) && compareDeep(creation, o.creation, true) 597 ; 598 } 599 600 @Override 601 public boolean equalsShallow(Base other) { 602 if (!super.equalsShallow(other)) 603 return false; 604 if (!(other instanceof Attachment)) 605 return false; 606 Attachment o = (Attachment) other; 607 return compareValues(contentType, o.contentType, true) && compareValues(language, o.language, true) 608 && compareValues(data, o.data, true) && compareValues(url, o.url, true) && compareValues(size, o.size, true) 609 && compareValues(hash, o.hash, true) && compareValues(title, o.title, true) && compareValues(creation, o.creation, true) 610 ; 611 } 612 613 public boolean isEmpty() { 614 return super.isEmpty() && (contentType == null || contentType.isEmpty()) && (language == null || language.isEmpty()) 615 && (data == null || data.isEmpty()) && (url == null || url.isEmpty()) && (size == null || size.isEmpty()) 616 && (hash == null || hash.isEmpty()) && (title == null || title.isEmpty()) && (creation == null || creation.isEmpty()) 617 ; 618 } 619 620 621} 622