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.ArrayList; 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 * There is a variety of postal address formats defined around the world. This format defines a superset that is the basis for all addresses around the world. 047 */ 048@DatatypeDef(name="Address") 049public class Address extends Type implements ICompositeType { 050 051 public enum AddressUse { 052 /** 053 * A communication address at a home. 054 */ 055 HOME, 056 /** 057 * An office address. First choice for business related contacts during business hours. 058 */ 059 WORK, 060 /** 061 * A temporary address. The period can provide more detailed information. 062 */ 063 TEMP, 064 /** 065 * This address is no longer in use (or was never correct, but retained for records). 066 */ 067 OLD, 068 /** 069 * added to help the parsers 070 */ 071 NULL; 072 public static AddressUse fromCode(String codeString) throws FHIRException { 073 if (codeString == null || "".equals(codeString)) 074 return null; 075 if ("home".equals(codeString)) 076 return HOME; 077 if ("work".equals(codeString)) 078 return WORK; 079 if ("temp".equals(codeString)) 080 return TEMP; 081 if ("old".equals(codeString)) 082 return OLD; 083 throw new FHIRException("Unknown AddressUse code '"+codeString+"'"); 084 } 085 public String toCode() { 086 switch (this) { 087 case HOME: return "home"; 088 case WORK: return "work"; 089 case TEMP: return "temp"; 090 case OLD: return "old"; 091 case NULL: return null; 092 default: return "?"; 093 } 094 } 095 public String getSystem() { 096 switch (this) { 097 case HOME: return "http://hl7.org/fhir/address-use"; 098 case WORK: return "http://hl7.org/fhir/address-use"; 099 case TEMP: return "http://hl7.org/fhir/address-use"; 100 case OLD: return "http://hl7.org/fhir/address-use"; 101 case NULL: return null; 102 default: return "?"; 103 } 104 } 105 public String getDefinition() { 106 switch (this) { 107 case HOME: return "A communication address at a home."; 108 case WORK: return "An office address. First choice for business related contacts during business hours."; 109 case TEMP: return "A temporary address. The period can provide more detailed information."; 110 case OLD: return "This address is no longer in use (or was never correct, but retained for records)."; 111 case NULL: return null; 112 default: return "?"; 113 } 114 } 115 public String getDisplay() { 116 switch (this) { 117 case HOME: return "Home"; 118 case WORK: return "Work"; 119 case TEMP: return "Temporary"; 120 case OLD: return "Old / Incorrect"; 121 case NULL: return null; 122 default: return "?"; 123 } 124 } 125 } 126 127 public static class AddressUseEnumFactory implements EnumFactory<AddressUse> { 128 public AddressUse fromCode(String codeString) throws IllegalArgumentException { 129 if (codeString == null || "".equals(codeString)) 130 if (codeString == null || "".equals(codeString)) 131 return null; 132 if ("home".equals(codeString)) 133 return AddressUse.HOME; 134 if ("work".equals(codeString)) 135 return AddressUse.WORK; 136 if ("temp".equals(codeString)) 137 return AddressUse.TEMP; 138 if ("old".equals(codeString)) 139 return AddressUse.OLD; 140 throw new IllegalArgumentException("Unknown AddressUse code '"+codeString+"'"); 141 } 142 public Enumeration<AddressUse> fromType(Base code) throws FHIRException { 143 if (code == null || code.isEmpty()) 144 return null; 145 String codeString = ((PrimitiveType) code).asStringValue(); 146 if (codeString == null || "".equals(codeString)) 147 return null; 148 if ("home".equals(codeString)) 149 return new Enumeration<AddressUse>(this, AddressUse.HOME); 150 if ("work".equals(codeString)) 151 return new Enumeration<AddressUse>(this, AddressUse.WORK); 152 if ("temp".equals(codeString)) 153 return new Enumeration<AddressUse>(this, AddressUse.TEMP); 154 if ("old".equals(codeString)) 155 return new Enumeration<AddressUse>(this, AddressUse.OLD); 156 throw new FHIRException("Unknown AddressUse code '"+codeString+"'"); 157 } 158 public String toCode(AddressUse code) { 159 if (code == AddressUse.HOME) 160 return "home"; 161 if (code == AddressUse.WORK) 162 return "work"; 163 if (code == AddressUse.TEMP) 164 return "temp"; 165 if (code == AddressUse.OLD) 166 return "old"; 167 return "?"; 168 } 169 } 170 171 public enum AddressType { 172 /** 173 * Mailing addresses - PO Boxes and care-of addresses. 174 */ 175 POSTAL, 176 /** 177 * A physical address that can be visited. 178 */ 179 PHYSICAL, 180 /** 181 * An address that is both physical and postal. 182 */ 183 BOTH, 184 /** 185 * added to help the parsers 186 */ 187 NULL; 188 public static AddressType fromCode(String codeString) throws FHIRException { 189 if (codeString == null || "".equals(codeString)) 190 return null; 191 if ("postal".equals(codeString)) 192 return POSTAL; 193 if ("physical".equals(codeString)) 194 return PHYSICAL; 195 if ("both".equals(codeString)) 196 return BOTH; 197 throw new FHIRException("Unknown AddressType code '"+codeString+"'"); 198 } 199 public String toCode() { 200 switch (this) { 201 case POSTAL: return "postal"; 202 case PHYSICAL: return "physical"; 203 case BOTH: return "both"; 204 case NULL: return null; 205 default: return "?"; 206 } 207 } 208 public String getSystem() { 209 switch (this) { 210 case POSTAL: return "http://hl7.org/fhir/address-type"; 211 case PHYSICAL: return "http://hl7.org/fhir/address-type"; 212 case BOTH: return "http://hl7.org/fhir/address-type"; 213 case NULL: return null; 214 default: return "?"; 215 } 216 } 217 public String getDefinition() { 218 switch (this) { 219 case POSTAL: return "Mailing addresses - PO Boxes and care-of addresses."; 220 case PHYSICAL: return "A physical address that can be visited."; 221 case BOTH: return "An address that is both physical and postal."; 222 case NULL: return null; 223 default: return "?"; 224 } 225 } 226 public String getDisplay() { 227 switch (this) { 228 case POSTAL: return "Postal"; 229 case PHYSICAL: return "Physical"; 230 case BOTH: return "Postal & Physical"; 231 case NULL: return null; 232 default: return "?"; 233 } 234 } 235 } 236 237 public static class AddressTypeEnumFactory implements EnumFactory<AddressType> { 238 public AddressType fromCode(String codeString) throws IllegalArgumentException { 239 if (codeString == null || "".equals(codeString)) 240 if (codeString == null || "".equals(codeString)) 241 return null; 242 if ("postal".equals(codeString)) 243 return AddressType.POSTAL; 244 if ("physical".equals(codeString)) 245 return AddressType.PHYSICAL; 246 if ("both".equals(codeString)) 247 return AddressType.BOTH; 248 throw new IllegalArgumentException("Unknown AddressType code '"+codeString+"'"); 249 } 250 public Enumeration<AddressType> fromType(Base code) throws FHIRException { 251 if (code == null || code.isEmpty()) 252 return null; 253 String codeString = ((PrimitiveType) code).asStringValue(); 254 if (codeString == null || "".equals(codeString)) 255 return null; 256 if ("postal".equals(codeString)) 257 return new Enumeration<AddressType>(this, AddressType.POSTAL); 258 if ("physical".equals(codeString)) 259 return new Enumeration<AddressType>(this, AddressType.PHYSICAL); 260 if ("both".equals(codeString)) 261 return new Enumeration<AddressType>(this, AddressType.BOTH); 262 throw new FHIRException("Unknown AddressType code '"+codeString+"'"); 263 } 264 public String toCode(AddressType code) { 265 if (code == AddressType.POSTAL) 266 return "postal"; 267 if (code == AddressType.PHYSICAL) 268 return "physical"; 269 if (code == AddressType.BOTH) 270 return "both"; 271 return "?"; 272 } 273 } 274 275 /** 276 * The purpose of this address. 277 */ 278 @Child(name = "use", type = {CodeType.class}, order=0, min=0, max=1, modifier=true, summary=true) 279 @Description(shortDefinition="home | work | temp | old - purpose of this address", formalDefinition="The purpose of this address." ) 280 protected Enumeration<AddressUse> use; 281 282 /** 283 * Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both. 284 */ 285 @Child(name = "type", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true) 286 @Description(shortDefinition="postal | physical | both", formalDefinition="Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both." ) 287 protected Enumeration<AddressType> type; 288 289 /** 290 * A full text representation of the address. 291 */ 292 @Child(name = "text", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true) 293 @Description(shortDefinition="Text representation of the address", formalDefinition="A full text representation of the address." ) 294 protected StringType text; 295 296 /** 297 * This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information. 298 */ 299 @Child(name = "line", type = {StringType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 300 @Description(shortDefinition="Street name, number, direction & P.O. Box etc.", formalDefinition="This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information." ) 301 protected List<StringType> line; 302 303 /** 304 * The name of the city, town, village or other community or delivery center. 305 */ 306 @Child(name = "city", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true) 307 @Description(shortDefinition="Name of city, town etc.", formalDefinition="The name of the city, town, village or other community or delivery center." ) 308 protected StringType city; 309 310 /** 311 * The name of the administrative area (county). 312 */ 313 @Child(name = "district", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true) 314 @Description(shortDefinition="District name (aka county)", formalDefinition="The name of the administrative area (county)." ) 315 protected StringType district; 316 317 /** 318 * Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (i.e. US 2 letter state codes). 319 */ 320 @Child(name = "state", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true) 321 @Description(shortDefinition="Sub-unit of country (abbreviations ok)", formalDefinition="Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (i.e. US 2 letter state codes)." ) 322 protected StringType state; 323 324 /** 325 * A postal code designating a region defined by the postal service. 326 */ 327 @Child(name = "postalCode", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=true) 328 @Description(shortDefinition="Postal code for area", formalDefinition="A postal code designating a region defined by the postal service." ) 329 protected StringType postalCode; 330 331 /** 332 * Country - a nation as commonly understood or generally accepted. 333 */ 334 @Child(name = "country", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=true) 335 @Description(shortDefinition="Country (can be ISO 3166 3 letter code)", formalDefinition="Country - a nation as commonly understood or generally accepted." ) 336 protected StringType country; 337 338 /** 339 * Time period when address was/is in use. 340 */ 341 @Child(name = "period", type = {Period.class}, order=9, min=0, max=1, modifier=false, summary=true) 342 @Description(shortDefinition="Time period when address was/is in use", formalDefinition="Time period when address was/is in use." ) 343 protected Period period; 344 345 private static final long serialVersionUID = 561490318L; 346 347 /* 348 * Constructor 349 */ 350 public Address() { 351 super(); 352 } 353 354 /** 355 * @return {@link #use} (The purpose of this address.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value 356 */ 357 public Enumeration<AddressUse> getUseElement() { 358 if (this.use == null) 359 if (Configuration.errorOnAutoCreate()) 360 throw new Error("Attempt to auto-create Address.use"); 361 else if (Configuration.doAutoCreate()) 362 this.use = new Enumeration<AddressUse>(new AddressUseEnumFactory()); // bb 363 return this.use; 364 } 365 366 public boolean hasUseElement() { 367 return this.use != null && !this.use.isEmpty(); 368 } 369 370 public boolean hasUse() { 371 return this.use != null && !this.use.isEmpty(); 372 } 373 374 /** 375 * @param value {@link #use} (The purpose of this address.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value 376 */ 377 public Address setUseElement(Enumeration<AddressUse> value) { 378 this.use = value; 379 return this; 380 } 381 382 /** 383 * @return The purpose of this address. 384 */ 385 public AddressUse getUse() { 386 return this.use == null ? null : this.use.getValue(); 387 } 388 389 /** 390 * @param value The purpose of this address. 391 */ 392 public Address setUse(AddressUse value) { 393 if (value == null) 394 this.use = null; 395 else { 396 if (this.use == null) 397 this.use = new Enumeration<AddressUse>(new AddressUseEnumFactory()); 398 this.use.setValue(value); 399 } 400 return this; 401 } 402 403 /** 404 * @return {@link #type} (Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 405 */ 406 public Enumeration<AddressType> getTypeElement() { 407 if (this.type == null) 408 if (Configuration.errorOnAutoCreate()) 409 throw new Error("Attempt to auto-create Address.type"); 410 else if (Configuration.doAutoCreate()) 411 this.type = new Enumeration<AddressType>(new AddressTypeEnumFactory()); // bb 412 return this.type; 413 } 414 415 public boolean hasTypeElement() { 416 return this.type != null && !this.type.isEmpty(); 417 } 418 419 public boolean hasType() { 420 return this.type != null && !this.type.isEmpty(); 421 } 422 423 /** 424 * @param value {@link #type} (Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 425 */ 426 public Address setTypeElement(Enumeration<AddressType> value) { 427 this.type = value; 428 return this; 429 } 430 431 /** 432 * @return Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both. 433 */ 434 public AddressType getType() { 435 return this.type == null ? null : this.type.getValue(); 436 } 437 438 /** 439 * @param value Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both. 440 */ 441 public Address setType(AddressType value) { 442 if (value == null) 443 this.type = null; 444 else { 445 if (this.type == null) 446 this.type = new Enumeration<AddressType>(new AddressTypeEnumFactory()); 447 this.type.setValue(value); 448 } 449 return this; 450 } 451 452 /** 453 * @return {@link #text} (A full text representation of the address.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 454 */ 455 public StringType getTextElement() { 456 if (this.text == null) 457 if (Configuration.errorOnAutoCreate()) 458 throw new Error("Attempt to auto-create Address.text"); 459 else if (Configuration.doAutoCreate()) 460 this.text = new StringType(); // bb 461 return this.text; 462 } 463 464 public boolean hasTextElement() { 465 return this.text != null && !this.text.isEmpty(); 466 } 467 468 public boolean hasText() { 469 return this.text != null && !this.text.isEmpty(); 470 } 471 472 /** 473 * @param value {@link #text} (A full text representation of the address.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 474 */ 475 public Address setTextElement(StringType value) { 476 this.text = value; 477 return this; 478 } 479 480 /** 481 * @return A full text representation of the address. 482 */ 483 public String getText() { 484 return this.text == null ? null : this.text.getValue(); 485 } 486 487 /** 488 * @param value A full text representation of the address. 489 */ 490 public Address setText(String value) { 491 if (Utilities.noString(value)) 492 this.text = null; 493 else { 494 if (this.text == null) 495 this.text = new StringType(); 496 this.text.setValue(value); 497 } 498 return this; 499 } 500 501 /** 502 * @return {@link #line} (This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.) 503 */ 504 public List<StringType> getLine() { 505 if (this.line == null) 506 this.line = new ArrayList<StringType>(); 507 return this.line; 508 } 509 510 public boolean hasLine() { 511 if (this.line == null) 512 return false; 513 for (StringType item : this.line) 514 if (!item.isEmpty()) 515 return true; 516 return false; 517 } 518 519 /** 520 * @return {@link #line} (This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.) 521 */ 522 // syntactic sugar 523 public StringType addLineElement() {//2 524 StringType t = new StringType(); 525 if (this.line == null) 526 this.line = new ArrayList<StringType>(); 527 this.line.add(t); 528 return t; 529 } 530 531 /** 532 * @param value {@link #line} (This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.) 533 */ 534 public Address addLine(String value) { //1 535 StringType t = new StringType(); 536 t.setValue(value); 537 if (this.line == null) 538 this.line = new ArrayList<StringType>(); 539 this.line.add(t); 540 return this; 541 } 542 543 /** 544 * @param value {@link #line} (This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.) 545 */ 546 public boolean hasLine(String value) { 547 if (this.line == null) 548 return false; 549 for (StringType v : this.line) 550 if (v.equals(value)) // string 551 return true; 552 return false; 553 } 554 555 /** 556 * @return {@link #city} (The name of the city, town, village or other community or delivery center.). This is the underlying object with id, value and extensions. The accessor "getCity" gives direct access to the value 557 */ 558 public StringType getCityElement() { 559 if (this.city == null) 560 if (Configuration.errorOnAutoCreate()) 561 throw new Error("Attempt to auto-create Address.city"); 562 else if (Configuration.doAutoCreate()) 563 this.city = new StringType(); // bb 564 return this.city; 565 } 566 567 public boolean hasCityElement() { 568 return this.city != null && !this.city.isEmpty(); 569 } 570 571 public boolean hasCity() { 572 return this.city != null && !this.city.isEmpty(); 573 } 574 575 /** 576 * @param value {@link #city} (The name of the city, town, village or other community or delivery center.). This is the underlying object with id, value and extensions. The accessor "getCity" gives direct access to the value 577 */ 578 public Address setCityElement(StringType value) { 579 this.city = value; 580 return this; 581 } 582 583 /** 584 * @return The name of the city, town, village or other community or delivery center. 585 */ 586 public String getCity() { 587 return this.city == null ? null : this.city.getValue(); 588 } 589 590 /** 591 * @param value The name of the city, town, village or other community or delivery center. 592 */ 593 public Address setCity(String value) { 594 if (Utilities.noString(value)) 595 this.city = null; 596 else { 597 if (this.city == null) 598 this.city = new StringType(); 599 this.city.setValue(value); 600 } 601 return this; 602 } 603 604 /** 605 * @return {@link #district} (The name of the administrative area (county).). This is the underlying object with id, value and extensions. The accessor "getDistrict" gives direct access to the value 606 */ 607 public StringType getDistrictElement() { 608 if (this.district == null) 609 if (Configuration.errorOnAutoCreate()) 610 throw new Error("Attempt to auto-create Address.district"); 611 else if (Configuration.doAutoCreate()) 612 this.district = new StringType(); // bb 613 return this.district; 614 } 615 616 public boolean hasDistrictElement() { 617 return this.district != null && !this.district.isEmpty(); 618 } 619 620 public boolean hasDistrict() { 621 return this.district != null && !this.district.isEmpty(); 622 } 623 624 /** 625 * @param value {@link #district} (The name of the administrative area (county).). This is the underlying object with id, value and extensions. The accessor "getDistrict" gives direct access to the value 626 */ 627 public Address setDistrictElement(StringType value) { 628 this.district = value; 629 return this; 630 } 631 632 /** 633 * @return The name of the administrative area (county). 634 */ 635 public String getDistrict() { 636 return this.district == null ? null : this.district.getValue(); 637 } 638 639 /** 640 * @param value The name of the administrative area (county). 641 */ 642 public Address setDistrict(String value) { 643 if (Utilities.noString(value)) 644 this.district = null; 645 else { 646 if (this.district == null) 647 this.district = new StringType(); 648 this.district.setValue(value); 649 } 650 return this; 651 } 652 653 /** 654 * @return {@link #state} (Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (i.e. US 2 letter state codes).). This is the underlying object with id, value and extensions. The accessor "getState" gives direct access to the value 655 */ 656 public StringType getStateElement() { 657 if (this.state == null) 658 if (Configuration.errorOnAutoCreate()) 659 throw new Error("Attempt to auto-create Address.state"); 660 else if (Configuration.doAutoCreate()) 661 this.state = new StringType(); // bb 662 return this.state; 663 } 664 665 public boolean hasStateElement() { 666 return this.state != null && !this.state.isEmpty(); 667 } 668 669 public boolean hasState() { 670 return this.state != null && !this.state.isEmpty(); 671 } 672 673 /** 674 * @param value {@link #state} (Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (i.e. US 2 letter state codes).). This is the underlying object with id, value and extensions. The accessor "getState" gives direct access to the value 675 */ 676 public Address setStateElement(StringType value) { 677 this.state = value; 678 return this; 679 } 680 681 /** 682 * @return Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (i.e. US 2 letter state codes). 683 */ 684 public String getState() { 685 return this.state == null ? null : this.state.getValue(); 686 } 687 688 /** 689 * @param value Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (i.e. US 2 letter state codes). 690 */ 691 public Address setState(String value) { 692 if (Utilities.noString(value)) 693 this.state = null; 694 else { 695 if (this.state == null) 696 this.state = new StringType(); 697 this.state.setValue(value); 698 } 699 return this; 700 } 701 702 /** 703 * @return {@link #postalCode} (A postal code designating a region defined by the postal service.). This is the underlying object with id, value and extensions. The accessor "getPostalCode" gives direct access to the value 704 */ 705 public StringType getPostalCodeElement() { 706 if (this.postalCode == null) 707 if (Configuration.errorOnAutoCreate()) 708 throw new Error("Attempt to auto-create Address.postalCode"); 709 else if (Configuration.doAutoCreate()) 710 this.postalCode = new StringType(); // bb 711 return this.postalCode; 712 } 713 714 public boolean hasPostalCodeElement() { 715 return this.postalCode != null && !this.postalCode.isEmpty(); 716 } 717 718 public boolean hasPostalCode() { 719 return this.postalCode != null && !this.postalCode.isEmpty(); 720 } 721 722 /** 723 * @param value {@link #postalCode} (A postal code designating a region defined by the postal service.). This is the underlying object with id, value and extensions. The accessor "getPostalCode" gives direct access to the value 724 */ 725 public Address setPostalCodeElement(StringType value) { 726 this.postalCode = value; 727 return this; 728 } 729 730 /** 731 * @return A postal code designating a region defined by the postal service. 732 */ 733 public String getPostalCode() { 734 return this.postalCode == null ? null : this.postalCode.getValue(); 735 } 736 737 /** 738 * @param value A postal code designating a region defined by the postal service. 739 */ 740 public Address setPostalCode(String value) { 741 if (Utilities.noString(value)) 742 this.postalCode = null; 743 else { 744 if (this.postalCode == null) 745 this.postalCode = new StringType(); 746 this.postalCode.setValue(value); 747 } 748 return this; 749 } 750 751 /** 752 * @return {@link #country} (Country - a nation as commonly understood or generally accepted.). This is the underlying object with id, value and extensions. The accessor "getCountry" gives direct access to the value 753 */ 754 public StringType getCountryElement() { 755 if (this.country == null) 756 if (Configuration.errorOnAutoCreate()) 757 throw new Error("Attempt to auto-create Address.country"); 758 else if (Configuration.doAutoCreate()) 759 this.country = new StringType(); // bb 760 return this.country; 761 } 762 763 public boolean hasCountryElement() { 764 return this.country != null && !this.country.isEmpty(); 765 } 766 767 public boolean hasCountry() { 768 return this.country != null && !this.country.isEmpty(); 769 } 770 771 /** 772 * @param value {@link #country} (Country - a nation as commonly understood or generally accepted.). This is the underlying object with id, value and extensions. The accessor "getCountry" gives direct access to the value 773 */ 774 public Address setCountryElement(StringType value) { 775 this.country = value; 776 return this; 777 } 778 779 /** 780 * @return Country - a nation as commonly understood or generally accepted. 781 */ 782 public String getCountry() { 783 return this.country == null ? null : this.country.getValue(); 784 } 785 786 /** 787 * @param value Country - a nation as commonly understood or generally accepted. 788 */ 789 public Address setCountry(String value) { 790 if (Utilities.noString(value)) 791 this.country = null; 792 else { 793 if (this.country == null) 794 this.country = new StringType(); 795 this.country.setValue(value); 796 } 797 return this; 798 } 799 800 /** 801 * @return {@link #period} (Time period when address was/is in use.) 802 */ 803 public Period getPeriod() { 804 if (this.period == null) 805 if (Configuration.errorOnAutoCreate()) 806 throw new Error("Attempt to auto-create Address.period"); 807 else if (Configuration.doAutoCreate()) 808 this.period = new Period(); // cc 809 return this.period; 810 } 811 812 public boolean hasPeriod() { 813 return this.period != null && !this.period.isEmpty(); 814 } 815 816 /** 817 * @param value {@link #period} (Time period when address was/is in use.) 818 */ 819 public Address setPeriod(Period value) { 820 this.period = value; 821 return this; 822 } 823 824 protected void listChildren(List<Property> childrenList) { 825 super.listChildren(childrenList); 826 childrenList.add(new Property("use", "code", "The purpose of this address.", 0, java.lang.Integer.MAX_VALUE, use)); 827 childrenList.add(new Property("type", "code", "Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.", 0, java.lang.Integer.MAX_VALUE, type)); 828 childrenList.add(new Property("text", "string", "A full text representation of the address.", 0, java.lang.Integer.MAX_VALUE, text)); 829 childrenList.add(new Property("line", "string", "This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.", 0, java.lang.Integer.MAX_VALUE, line)); 830 childrenList.add(new Property("city", "string", "The name of the city, town, village or other community or delivery center.", 0, java.lang.Integer.MAX_VALUE, city)); 831 childrenList.add(new Property("district", "string", "The name of the administrative area (county).", 0, java.lang.Integer.MAX_VALUE, district)); 832 childrenList.add(new Property("state", "string", "Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (i.e. US 2 letter state codes).", 0, java.lang.Integer.MAX_VALUE, state)); 833 childrenList.add(new Property("postalCode", "string", "A postal code designating a region defined by the postal service.", 0, java.lang.Integer.MAX_VALUE, postalCode)); 834 childrenList.add(new Property("country", "string", "Country - a nation as commonly understood or generally accepted.", 0, java.lang.Integer.MAX_VALUE, country)); 835 childrenList.add(new Property("period", "Period", "Time period when address was/is in use.", 0, java.lang.Integer.MAX_VALUE, period)); 836 } 837 838 @Override 839 public void setProperty(String name, Base value) throws FHIRException { 840 if (name.equals("use")) 841 this.use = new AddressUseEnumFactory().fromType(value); // Enumeration<AddressUse> 842 else if (name.equals("type")) 843 this.type = new AddressTypeEnumFactory().fromType(value); // Enumeration<AddressType> 844 else if (name.equals("text")) 845 this.text = castToString(value); // StringType 846 else if (name.equals("line")) 847 this.getLine().add(castToString(value)); 848 else if (name.equals("city")) 849 this.city = castToString(value); // StringType 850 else if (name.equals("district")) 851 this.district = castToString(value); // StringType 852 else if (name.equals("state")) 853 this.state = castToString(value); // StringType 854 else if (name.equals("postalCode")) 855 this.postalCode = castToString(value); // StringType 856 else if (name.equals("country")) 857 this.country = castToString(value); // StringType 858 else if (name.equals("period")) 859 this.period = castToPeriod(value); // Period 860 else 861 super.setProperty(name, value); 862 } 863 864 @Override 865 public Base addChild(String name) throws FHIRException { 866 if (name.equals("use")) { 867 throw new FHIRException("Cannot call addChild on a primitive type Address.use"); 868 } 869 else if (name.equals("type")) { 870 throw new FHIRException("Cannot call addChild on a primitive type Address.type"); 871 } 872 else if (name.equals("text")) { 873 throw new FHIRException("Cannot call addChild on a primitive type Address.text"); 874 } 875 else if (name.equals("line")) { 876 throw new FHIRException("Cannot call addChild on a primitive type Address.line"); 877 } 878 else if (name.equals("city")) { 879 throw new FHIRException("Cannot call addChild on a primitive type Address.city"); 880 } 881 else if (name.equals("district")) { 882 throw new FHIRException("Cannot call addChild on a primitive type Address.district"); 883 } 884 else if (name.equals("state")) { 885 throw new FHIRException("Cannot call addChild on a primitive type Address.state"); 886 } 887 else if (name.equals("postalCode")) { 888 throw new FHIRException("Cannot call addChild on a primitive type Address.postalCode"); 889 } 890 else if (name.equals("country")) { 891 throw new FHIRException("Cannot call addChild on a primitive type Address.country"); 892 } 893 else if (name.equals("period")) { 894 this.period = new Period(); 895 return this.period; 896 } 897 else 898 return super.addChild(name); 899 } 900 901 public String fhirType() { 902 return "Address"; 903 904 } 905 906 public Address copy() { 907 Address dst = new Address(); 908 copyValues(dst); 909 dst.use = use == null ? null : use.copy(); 910 dst.type = type == null ? null : type.copy(); 911 dst.text = text == null ? null : text.copy(); 912 if (line != null) { 913 dst.line = new ArrayList<StringType>(); 914 for (StringType i : line) 915 dst.line.add(i.copy()); 916 }; 917 dst.city = city == null ? null : city.copy(); 918 dst.district = district == null ? null : district.copy(); 919 dst.state = state == null ? null : state.copy(); 920 dst.postalCode = postalCode == null ? null : postalCode.copy(); 921 dst.country = country == null ? null : country.copy(); 922 dst.period = period == null ? null : period.copy(); 923 return dst; 924 } 925 926 protected Address typedCopy() { 927 return copy(); 928 } 929 930 @Override 931 public boolean equalsDeep(Base other) { 932 if (!super.equalsDeep(other)) 933 return false; 934 if (!(other instanceof Address)) 935 return false; 936 Address o = (Address) other; 937 return compareDeep(use, o.use, true) && compareDeep(type, o.type, true) && compareDeep(text, o.text, true) 938 && compareDeep(line, o.line, true) && compareDeep(city, o.city, true) && compareDeep(district, o.district, true) 939 && compareDeep(state, o.state, true) && compareDeep(postalCode, o.postalCode, true) && compareDeep(country, o.country, true) 940 && compareDeep(period, o.period, true); 941 } 942 943 @Override 944 public boolean equalsShallow(Base other) { 945 if (!super.equalsShallow(other)) 946 return false; 947 if (!(other instanceof Address)) 948 return false; 949 Address o = (Address) other; 950 return compareValues(use, o.use, true) && compareValues(type, o.type, true) && compareValues(text, o.text, true) 951 && compareValues(line, o.line, true) && compareValues(city, o.city, true) && compareValues(district, o.district, true) 952 && compareValues(state, o.state, true) && compareValues(postalCode, o.postalCode, true) && compareValues(country, o.country, true) 953 ; 954 } 955 956 public boolean isEmpty() { 957 return super.isEmpty() && (use == null || use.isEmpty()) && (type == null || type.isEmpty()) 958 && (text == null || text.isEmpty()) && (line == null || line.isEmpty()) && (city == null || city.isEmpty()) 959 && (district == null || district.isEmpty()) && (state == null || state.isEmpty()) && (postalCode == null || postalCode.isEmpty()) 960 && (country == null || country.isEmpty()) && (period == null || period.isEmpty()); 961 } 962 963 964}