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