001package org.hl7.fhir.r4.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 Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
033import java.util.ArrayList;
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.Child;
041import ca.uhn.fhir.model.api.annotation.DatatypeDef;
042import ca.uhn.fhir.model.api.annotation.Description;
043
044/**
045 * An address expressed using postal conventions (as opposed to GPS or other
046 * location definition formats). This data type may be used to convey addresses
047 * for use in delivering mail as well as for visiting locations which might not
048 * be valid for mail delivery. There are a variety of postal address formats
049 * defined around the world.
050 */
051@DatatypeDef(name = "Address")
052public class Address extends Type implements ICompositeType {
053
054  public enum AddressUse {
055    /**
056     * A communication address at a home.
057     */
058    HOME,
059    /**
060     * An office address. First choice for business related contacts during business
061     * hours.
062     */
063    WORK,
064    /**
065     * A temporary address. The period can provide more detailed information.
066     */
067    TEMP,
068    /**
069     * This address is no longer in use (or was never correct but retained for
070     * records).
071     */
072    OLD,
073    /**
074     * An address to be used to send bills, invoices, receipts etc.
075     */
076    BILLING,
077    /**
078     * added to help the parsers with the generic types
079     */
080    NULL;
081
082    public static AddressUse fromCode(String codeString) throws FHIRException {
083      if (codeString == null || "".equals(codeString))
084        return null;
085      if ("home".equals(codeString))
086        return HOME;
087      if ("work".equals(codeString))
088        return WORK;
089      if ("temp".equals(codeString))
090        return TEMP;
091      if ("old".equals(codeString))
092        return OLD;
093      if ("billing".equals(codeString))
094        return BILLING;
095      if (Configuration.isAcceptInvalidEnums())
096        return null;
097      else
098        throw new FHIRException("Unknown AddressUse code '" + codeString + "'");
099    }
100
101    public String toCode() {
102      switch (this) {
103      case HOME:
104        return "home";
105      case WORK:
106        return "work";
107      case TEMP:
108        return "temp";
109      case OLD:
110        return "old";
111      case BILLING:
112        return "billing";
113      case NULL:
114        return null;
115      default:
116        return "?";
117      }
118    }
119
120    public String getSystem() {
121      switch (this) {
122      case HOME:
123        return "http://hl7.org/fhir/address-use";
124      case WORK:
125        return "http://hl7.org/fhir/address-use";
126      case TEMP:
127        return "http://hl7.org/fhir/address-use";
128      case OLD:
129        return "http://hl7.org/fhir/address-use";
130      case BILLING:
131        return "http://hl7.org/fhir/address-use";
132      case NULL:
133        return null;
134      default:
135        return "?";
136      }
137    }
138
139    public String getDefinition() {
140      switch (this) {
141      case HOME:
142        return "A communication address at a home.";
143      case WORK:
144        return "An office address. First choice for business related contacts during business hours.";
145      case TEMP:
146        return "A temporary address. The period can provide more detailed information.";
147      case OLD:
148        return "This address is no longer in use (or was never correct but retained for records).";
149      case BILLING:
150        return "An address to be used to send bills, invoices, receipts etc.";
151      case NULL:
152        return null;
153      default:
154        return "?";
155      }
156    }
157
158    public String getDisplay() {
159      switch (this) {
160      case HOME:
161        return "Home";
162      case WORK:
163        return "Work";
164      case TEMP:
165        return "Temporary";
166      case OLD:
167        return "Old / Incorrect";
168      case BILLING:
169        return "Billing";
170      case NULL:
171        return null;
172      default:
173        return "?";
174      }
175    }
176  }
177
178  public static class AddressUseEnumFactory implements EnumFactory<AddressUse> {
179    public AddressUse fromCode(String codeString) throws IllegalArgumentException {
180      if (codeString == null || "".equals(codeString))
181        if (codeString == null || "".equals(codeString))
182          return null;
183      if ("home".equals(codeString))
184        return AddressUse.HOME;
185      if ("work".equals(codeString))
186        return AddressUse.WORK;
187      if ("temp".equals(codeString))
188        return AddressUse.TEMP;
189      if ("old".equals(codeString))
190        return AddressUse.OLD;
191      if ("billing".equals(codeString))
192        return AddressUse.BILLING;
193      throw new IllegalArgumentException("Unknown AddressUse code '" + codeString + "'");
194    }
195
196    public Enumeration<AddressUse> fromType(PrimitiveType<?> code) throws FHIRException {
197      if (code == null)
198        return null;
199      if (code.isEmpty())
200        return new Enumeration<AddressUse>(this, AddressUse.NULL, code);
201      String codeString = code.asStringValue();
202      if (codeString == null || "".equals(codeString))
203        return new Enumeration<AddressUse>(this, AddressUse.NULL, code);
204      if ("home".equals(codeString))
205        return new Enumeration<AddressUse>(this, AddressUse.HOME, code);
206      if ("work".equals(codeString))
207        return new Enumeration<AddressUse>(this, AddressUse.WORK, code);
208      if ("temp".equals(codeString))
209        return new Enumeration<AddressUse>(this, AddressUse.TEMP, code);
210      if ("old".equals(codeString))
211        return new Enumeration<AddressUse>(this, AddressUse.OLD, code);
212      if ("billing".equals(codeString))
213        return new Enumeration<AddressUse>(this, AddressUse.BILLING, code);
214      throw new FHIRException("Unknown AddressUse code '" + codeString + "'");
215    }
216
217    public String toCode(AddressUse code) {
218      if (code == AddressUse.HOME)
219        return "home";
220      if (code == AddressUse.WORK)
221        return "work";
222      if (code == AddressUse.TEMP)
223        return "temp";
224      if (code == AddressUse.OLD)
225        return "old";
226      if (code == AddressUse.BILLING)
227        return "billing";
228      return "?";
229    }
230
231    public String toSystem(AddressUse code) {
232      return code.getSystem();
233    }
234  }
235
236  public enum AddressType {
237    /**
238     * Mailing addresses - PO Boxes and care-of addresses.
239     */
240    POSTAL,
241    /**
242     * A physical address that can be visited.
243     */
244    PHYSICAL,
245    /**
246     * An address that is both physical and postal.
247     */
248    BOTH,
249    /**
250     * added to help the parsers with the generic types
251     */
252    NULL;
253
254    public static AddressType fromCode(String codeString) throws FHIRException {
255      if (codeString == null || "".equals(codeString))
256        return null;
257      if ("postal".equals(codeString))
258        return POSTAL;
259      if ("physical".equals(codeString))
260        return PHYSICAL;
261      if ("both".equals(codeString))
262        return BOTH;
263      if (Configuration.isAcceptInvalidEnums())
264        return null;
265      else
266        throw new FHIRException("Unknown AddressType code '" + codeString + "'");
267    }
268
269    public String toCode() {
270      switch (this) {
271      case POSTAL:
272        return "postal";
273      case PHYSICAL:
274        return "physical";
275      case BOTH:
276        return "both";
277      case NULL:
278        return null;
279      default:
280        return "?";
281      }
282    }
283
284    public String getSystem() {
285      switch (this) {
286      case POSTAL:
287        return "http://hl7.org/fhir/address-type";
288      case PHYSICAL:
289        return "http://hl7.org/fhir/address-type";
290      case BOTH:
291        return "http://hl7.org/fhir/address-type";
292      case NULL:
293        return null;
294      default:
295        return "?";
296      }
297    }
298
299    public String getDefinition() {
300      switch (this) {
301      case POSTAL:
302        return "Mailing addresses - PO Boxes and care-of addresses.";
303      case PHYSICAL:
304        return "A physical address that can be visited.";
305      case BOTH:
306        return "An address that is both physical and postal.";
307      case NULL:
308        return null;
309      default:
310        return "?";
311      }
312    }
313
314    public String getDisplay() {
315      switch (this) {
316      case POSTAL:
317        return "Postal";
318      case PHYSICAL:
319        return "Physical";
320      case BOTH:
321        return "Postal & Physical";
322      case NULL:
323        return null;
324      default:
325        return "?";
326      }
327    }
328  }
329
330  public static class AddressTypeEnumFactory implements EnumFactory<AddressType> {
331    public AddressType fromCode(String codeString) throws IllegalArgumentException {
332      if (codeString == null || "".equals(codeString))
333        if (codeString == null || "".equals(codeString))
334          return null;
335      if ("postal".equals(codeString))
336        return AddressType.POSTAL;
337      if ("physical".equals(codeString))
338        return AddressType.PHYSICAL;
339      if ("both".equals(codeString))
340        return AddressType.BOTH;
341      throw new IllegalArgumentException("Unknown AddressType code '" + codeString + "'");
342    }
343
344    public Enumeration<AddressType> fromType(PrimitiveType<?> code) throws FHIRException {
345      if (code == null)
346        return null;
347      if (code.isEmpty())
348        return new Enumeration<AddressType>(this, AddressType.NULL, code);
349      String codeString = code.asStringValue();
350      if (codeString == null || "".equals(codeString))
351        return new Enumeration<AddressType>(this, AddressType.NULL, code);
352      if ("postal".equals(codeString))
353        return new Enumeration<AddressType>(this, AddressType.POSTAL, code);
354      if ("physical".equals(codeString))
355        return new Enumeration<AddressType>(this, AddressType.PHYSICAL, code);
356      if ("both".equals(codeString))
357        return new Enumeration<AddressType>(this, AddressType.BOTH, code);
358      throw new FHIRException("Unknown AddressType code '" + codeString + "'");
359    }
360
361    public String toCode(AddressType code) {
362      if (code == AddressType.POSTAL)
363        return "postal";
364      if (code == AddressType.PHYSICAL)
365        return "physical";
366      if (code == AddressType.BOTH)
367        return "both";
368      return "?";
369    }
370
371    public String toSystem(AddressType code) {
372      return code.getSystem();
373    }
374  }
375
376  /**
377   * The purpose of this address.
378   */
379  @Child(name = "use", type = { CodeType.class }, order = 0, min = 0, max = 1, modifier = true, summary = true)
380  @Description(shortDefinition = "home | work | temp | old | billing - purpose of this address", formalDefinition = "The purpose of this address.")
381  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/address-use")
382  protected Enumeration<AddressUse> use;
383
384  /**
385   * Distinguishes between physical addresses (those you can visit) and mailing
386   * addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.
387   */
388  @Child(name = "type", type = { CodeType.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
389  @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.")
390  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/address-type")
391  protected Enumeration<AddressType> type;
392
393  /**
394   * Specifies the entire address as it should be displayed e.g. on a postal
395   * label. This may be provided instead of or as well as the specific parts.
396   */
397  @Child(name = "text", type = { StringType.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
398  @Description(shortDefinition = "Text representation of the address", formalDefinition = "Specifies the entire address as it should be displayed e.g. on a postal label. This may be provided instead of or as well as the specific parts.")
399  protected StringType text;
400
401  /**
402   * This component contains the house number, apartment number, street name,
403   * street direction, P.O. Box number, delivery hints, and similar address
404   * information.
405   */
406  @Child(name = "line", type = {
407      StringType.class }, order = 3, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
408  @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.")
409  protected List<StringType> line;
410
411  /**
412   * The name of the city, town, suburb, village or other community or delivery
413   * center.
414   */
415  @Child(name = "city", type = { StringType.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
416  @Description(shortDefinition = "Name of city, town etc.", formalDefinition = "The name of the city, town, suburb, village or other community or delivery center.")
417  protected StringType city;
418
419  /**
420   * The name of the administrative area (county).
421   */
422  @Child(name = "district", type = { StringType.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
423  @Description(shortDefinition = "District name (aka county)", formalDefinition = "The name of the administrative area (county).")
424  protected StringType district;
425
426  /**
427   * Sub-unit of a country with limited sovereignty in a federally organized
428   * country. A code may be used if codes are in common use (e.g. US 2 letter
429   * state codes).
430   */
431  @Child(name = "state", type = { StringType.class }, order = 6, min = 0, max = 1, modifier = false, summary = true)
432  @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 (e.g. US 2 letter state codes).")
433  protected StringType state;
434
435  /**
436   * A postal code designating a region defined by the postal service.
437   */
438  @Child(name = "postalCode", type = {
439      StringType.class }, order = 7, min = 0, max = 1, modifier = false, summary = true)
440  @Description(shortDefinition = "Postal code for area", formalDefinition = "A postal code designating a region defined by the postal service.")
441  protected StringType postalCode;
442
443  /**
444   * Country - a nation as commonly understood or generally accepted.
445   */
446  @Child(name = "country", type = { StringType.class }, order = 8, min = 0, max = 1, modifier = false, summary = true)
447  @Description(shortDefinition = "Country (e.g. can be ISO 3166 2 or 3 letter code)", formalDefinition = "Country - a nation as commonly understood or generally accepted.")
448  protected StringType country;
449
450  /**
451   * Time period when address was/is in use.
452   */
453  @Child(name = "period", type = { Period.class }, order = 9, min = 0, max = 1, modifier = false, summary = true)
454  @Description(shortDefinition = "Time period when address was/is in use", formalDefinition = "Time period when address was/is in use.")
455  protected Period period;
456
457  private static final long serialVersionUID = 561490318L;
458
459  /**
460   * Constructor
461   */
462  public Address() {
463    super();
464  }
465
466  /**
467   * @return {@link #use} (The purpose of this address.). This is the underlying
468   *         object with id, value and extensions. The accessor "getUse" gives
469   *         direct access to the value
470   */
471  public Enumeration<AddressUse> getUseElement() {
472    if (this.use == null)
473      if (Configuration.errorOnAutoCreate())
474        throw new Error("Attempt to auto-create Address.use");
475      else if (Configuration.doAutoCreate())
476        this.use = new Enumeration<AddressUse>(new AddressUseEnumFactory()); // bb
477    return this.use;
478  }
479
480  public boolean hasUseElement() {
481    return this.use != null && !this.use.isEmpty();
482  }
483
484  public boolean hasUse() {
485    return this.use != null && !this.use.isEmpty();
486  }
487
488  /**
489   * @param value {@link #use} (The purpose of this address.). This is the
490   *              underlying object with id, value and extensions. The accessor
491   *              "getUse" gives direct access to the value
492   */
493  public Address setUseElement(Enumeration<AddressUse> value) {
494    this.use = value;
495    return this;
496  }
497
498  /**
499   * @return The purpose of this address.
500   */
501  public AddressUse getUse() {
502    return this.use == null ? null : this.use.getValue();
503  }
504
505  /**
506   * @param value The purpose of this address.
507   */
508  public Address setUse(AddressUse value) {
509    if (value == null)
510      this.use = null;
511    else {
512      if (this.use == null)
513        this.use = new Enumeration<AddressUse>(new AddressUseEnumFactory());
514      this.use.setValue(value);
515    }
516    return this;
517  }
518
519  /**
520   * @return {@link #type} (Distinguishes between physical addresses (those you
521   *         can visit) and mailing addresses (e.g. PO Boxes and care-of
522   *         addresses). Most addresses are both.). This is the underlying object
523   *         with id, value and extensions. The accessor "getType" gives direct
524   *         access to the value
525   */
526  public Enumeration<AddressType> getTypeElement() {
527    if (this.type == null)
528      if (Configuration.errorOnAutoCreate())
529        throw new Error("Attempt to auto-create Address.type");
530      else if (Configuration.doAutoCreate())
531        this.type = new Enumeration<AddressType>(new AddressTypeEnumFactory()); // bb
532    return this.type;
533  }
534
535  public boolean hasTypeElement() {
536    return this.type != null && !this.type.isEmpty();
537  }
538
539  public boolean hasType() {
540    return this.type != null && !this.type.isEmpty();
541  }
542
543  /**
544   * @param value {@link #type} (Distinguishes between physical addresses (those
545   *              you can visit) and mailing addresses (e.g. PO Boxes and care-of
546   *              addresses). Most addresses are both.). This is the underlying
547   *              object with id, value and extensions. The accessor "getType"
548   *              gives direct access to the value
549   */
550  public Address setTypeElement(Enumeration<AddressType> value) {
551    this.type = value;
552    return this;
553  }
554
555  /**
556   * @return Distinguishes between physical addresses (those you can visit) and
557   *         mailing addresses (e.g. PO Boxes and care-of addresses). Most
558   *         addresses are both.
559   */
560  public AddressType getType() {
561    return this.type == null ? null : this.type.getValue();
562  }
563
564  /**
565   * @param value Distinguishes between physical addresses (those you can visit)
566   *              and mailing addresses (e.g. PO Boxes and care-of addresses).
567   *              Most addresses are both.
568   */
569  public Address setType(AddressType value) {
570    if (value == null)
571      this.type = null;
572    else {
573      if (this.type == null)
574        this.type = new Enumeration<AddressType>(new AddressTypeEnumFactory());
575      this.type.setValue(value);
576    }
577    return this;
578  }
579
580  /**
581   * @return {@link #text} (Specifies the entire address as it should be displayed
582   *         e.g. on a postal label. This may be provided instead of or as well as
583   *         the specific parts.). This is the underlying object with id, value
584   *         and extensions. The accessor "getText" gives direct access to the
585   *         value
586   */
587  public StringType getTextElement() {
588    if (this.text == null)
589      if (Configuration.errorOnAutoCreate())
590        throw new Error("Attempt to auto-create Address.text");
591      else if (Configuration.doAutoCreate())
592        this.text = new StringType(); // bb
593    return this.text;
594  }
595
596  public boolean hasTextElement() {
597    return this.text != null && !this.text.isEmpty();
598  }
599
600  public boolean hasText() {
601    return this.text != null && !this.text.isEmpty();
602  }
603
604  /**
605   * @param value {@link #text} (Specifies the entire address as it should be
606   *              displayed e.g. on a postal label. This may be provided instead
607   *              of or as well as the specific parts.). This is the underlying
608   *              object with id, value and extensions. The accessor "getText"
609   *              gives direct access to the value
610   */
611  public Address setTextElement(StringType value) {
612    this.text = value;
613    return this;
614  }
615
616  /**
617   * @return Specifies the entire address as it should be displayed e.g. on a
618   *         postal label. This may be provided instead of or as well as the
619   *         specific parts.
620   */
621  public String getText() {
622    return this.text == null ? null : this.text.getValue();
623  }
624
625  /**
626   * @param value Specifies the entire address as it should be displayed e.g. on a
627   *              postal label. This may be provided instead of or as well as the
628   *              specific parts.
629   */
630  public Address setText(String value) {
631    if (Utilities.noString(value))
632      this.text = null;
633    else {
634      if (this.text == null)
635        this.text = new StringType();
636      this.text.setValue(value);
637    }
638    return this;
639  }
640
641  /**
642   * @return {@link #line} (This component contains the house number, apartment
643   *         number, street name, street direction, P.O. Box number, delivery
644   *         hints, and similar address information.)
645   */
646  public List<StringType> getLine() {
647    if (this.line == null)
648      this.line = new ArrayList<StringType>();
649    return this.line;
650  }
651
652  /**
653   * @return Returns a reference to <code>this</code> for easy method chaining
654   */
655  public Address setLine(List<StringType> theLine) {
656    this.line = theLine;
657    return this;
658  }
659
660  public boolean hasLine() {
661    if (this.line == null)
662      return false;
663    for (StringType item : this.line)
664      if (!item.isEmpty())
665        return true;
666    return false;
667  }
668
669  /**
670   * @return {@link #line} (This component contains the house number, apartment
671   *         number, street name, street direction, P.O. Box number, delivery
672   *         hints, and similar address information.)
673   */
674  public StringType addLineElement() {// 2
675    StringType t = new StringType();
676    if (this.line == null)
677      this.line = new ArrayList<StringType>();
678    this.line.add(t);
679    return t;
680  }
681
682  /**
683   * @param value {@link #line} (This component contains the house number,
684   *              apartment number, street name, street direction, P.O. Box
685   *              number, delivery hints, and similar address information.)
686   */
687  public Address addLine(String value) { // 1
688    StringType t = new StringType();
689    t.setValue(value);
690    if (this.line == null)
691      this.line = new ArrayList<StringType>();
692    this.line.add(t);
693    return this;
694  }
695
696  /**
697   * @param value {@link #line} (This component contains the house number,
698   *              apartment number, street name, street direction, P.O. Box
699   *              number, delivery hints, and similar address information.)
700   */
701  public boolean hasLine(String value) {
702    if (this.line == null)
703      return false;
704    for (StringType v : this.line)
705      if (v.getValue().equals(value)) // string
706        return true;
707    return false;
708  }
709
710  /**
711   * @return {@link #city} (The name of the city, town, suburb, village or other
712   *         community or delivery center.). This is the underlying object with
713   *         id, value and extensions. The accessor "getCity" gives direct access
714   *         to the value
715   */
716  public StringType getCityElement() {
717    if (this.city == null)
718      if (Configuration.errorOnAutoCreate())
719        throw new Error("Attempt to auto-create Address.city");
720      else if (Configuration.doAutoCreate())
721        this.city = new StringType(); // bb
722    return this.city;
723  }
724
725  public boolean hasCityElement() {
726    return this.city != null && !this.city.isEmpty();
727  }
728
729  public boolean hasCity() {
730    return this.city != null && !this.city.isEmpty();
731  }
732
733  /**
734   * @param value {@link #city} (The name of the city, town, suburb, village or
735   *              other community or delivery center.). This is the underlying
736   *              object with id, value and extensions. The accessor "getCity"
737   *              gives direct access to the value
738   */
739  public Address setCityElement(StringType value) {
740    this.city = value;
741    return this;
742  }
743
744  /**
745   * @return The name of the city, town, suburb, village or other community or
746   *         delivery center.
747   */
748  public String getCity() {
749    return this.city == null ? null : this.city.getValue();
750  }
751
752  /**
753   * @param value The name of the city, town, suburb, village or other community
754   *              or delivery center.
755   */
756  public Address setCity(String value) {
757    if (Utilities.noString(value))
758      this.city = null;
759    else {
760      if (this.city == null)
761        this.city = new StringType();
762      this.city.setValue(value);
763    }
764    return this;
765  }
766
767  /**
768   * @return {@link #district} (The name of the administrative area (county).).
769   *         This is the underlying object with id, value and extensions. The
770   *         accessor "getDistrict" gives direct access to the value
771   */
772  public StringType getDistrictElement() {
773    if (this.district == null)
774      if (Configuration.errorOnAutoCreate())
775        throw new Error("Attempt to auto-create Address.district");
776      else if (Configuration.doAutoCreate())
777        this.district = new StringType(); // bb
778    return this.district;
779  }
780
781  public boolean hasDistrictElement() {
782    return this.district != null && !this.district.isEmpty();
783  }
784
785  public boolean hasDistrict() {
786    return this.district != null && !this.district.isEmpty();
787  }
788
789  /**
790   * @param value {@link #district} (The name of the administrative area
791   *              (county).). This is the underlying object with id, value and
792   *              extensions. The accessor "getDistrict" gives direct access to
793   *              the value
794   */
795  public Address setDistrictElement(StringType value) {
796    this.district = value;
797    return this;
798  }
799
800  /**
801   * @return The name of the administrative area (county).
802   */
803  public String getDistrict() {
804    return this.district == null ? null : this.district.getValue();
805  }
806
807  /**
808   * @param value The name of the administrative area (county).
809   */
810  public Address setDistrict(String value) {
811    if (Utilities.noString(value))
812      this.district = null;
813    else {
814      if (this.district == null)
815        this.district = new StringType();
816      this.district.setValue(value);
817    }
818    return this;
819  }
820
821  /**
822   * @return {@link #state} (Sub-unit of a country with limited sovereignty in a
823   *         federally organized country. A code may be used if codes are in
824   *         common use (e.g. US 2 letter state codes).). This is the underlying
825   *         object with id, value and extensions. The accessor "getState" gives
826   *         direct access to the value
827   */
828  public StringType getStateElement() {
829    if (this.state == null)
830      if (Configuration.errorOnAutoCreate())
831        throw new Error("Attempt to auto-create Address.state");
832      else if (Configuration.doAutoCreate())
833        this.state = new StringType(); // bb
834    return this.state;
835  }
836
837  public boolean hasStateElement() {
838    return this.state != null && !this.state.isEmpty();
839  }
840
841  public boolean hasState() {
842    return this.state != null && !this.state.isEmpty();
843  }
844
845  /**
846   * @param value {@link #state} (Sub-unit of a country with limited sovereignty
847   *              in a federally organized country. A code may be used if codes
848   *              are in common use (e.g. US 2 letter state codes).). This is the
849   *              underlying object with id, value and extensions. The accessor
850   *              "getState" gives direct access to the value
851   */
852  public Address setStateElement(StringType value) {
853    this.state = value;
854    return this;
855  }
856
857  /**
858   * @return Sub-unit of a country with limited sovereignty in a federally
859   *         organized country. A code may be used if codes are in common use
860   *         (e.g. US 2 letter state codes).
861   */
862  public String getState() {
863    return this.state == null ? null : this.state.getValue();
864  }
865
866  /**
867   * @param value Sub-unit of a country with limited sovereignty in a federally
868   *              organized country. A code may be used if codes are in common use
869   *              (e.g. US 2 letter state codes).
870   */
871  public Address setState(String value) {
872    if (Utilities.noString(value))
873      this.state = null;
874    else {
875      if (this.state == null)
876        this.state = new StringType();
877      this.state.setValue(value);
878    }
879    return this;
880  }
881
882  /**
883   * @return {@link #postalCode} (A postal code designating a region defined by
884   *         the postal service.). This is the underlying object with id, value
885   *         and extensions. The accessor "getPostalCode" gives direct access to
886   *         the value
887   */
888  public StringType getPostalCodeElement() {
889    if (this.postalCode == null)
890      if (Configuration.errorOnAutoCreate())
891        throw new Error("Attempt to auto-create Address.postalCode");
892      else if (Configuration.doAutoCreate())
893        this.postalCode = new StringType(); // bb
894    return this.postalCode;
895  }
896
897  public boolean hasPostalCodeElement() {
898    return this.postalCode != null && !this.postalCode.isEmpty();
899  }
900
901  public boolean hasPostalCode() {
902    return this.postalCode != null && !this.postalCode.isEmpty();
903  }
904
905  /**
906   * @param value {@link #postalCode} (A postal code designating a region defined
907   *              by the postal service.). This is the underlying object with id,
908   *              value and extensions. The accessor "getPostalCode" gives direct
909   *              access to the value
910   */
911  public Address setPostalCodeElement(StringType value) {
912    this.postalCode = value;
913    return this;
914  }
915
916  /**
917   * @return A postal code designating a region defined by the postal service.
918   */
919  public String getPostalCode() {
920    return this.postalCode == null ? null : this.postalCode.getValue();
921  }
922
923  /**
924   * @param value A postal code designating a region defined by the postal
925   *              service.
926   */
927  public Address setPostalCode(String value) {
928    if (Utilities.noString(value))
929      this.postalCode = null;
930    else {
931      if (this.postalCode == null)
932        this.postalCode = new StringType();
933      this.postalCode.setValue(value);
934    }
935    return this;
936  }
937
938  /**
939   * @return {@link #country} (Country - a nation as commonly understood or
940   *         generally accepted.). This is the underlying object with id, value
941   *         and extensions. The accessor "getCountry" gives direct access to the
942   *         value
943   */
944  public StringType getCountryElement() {
945    if (this.country == null)
946      if (Configuration.errorOnAutoCreate())
947        throw new Error("Attempt to auto-create Address.country");
948      else if (Configuration.doAutoCreate())
949        this.country = new StringType(); // bb
950    return this.country;
951  }
952
953  public boolean hasCountryElement() {
954    return this.country != null && !this.country.isEmpty();
955  }
956
957  public boolean hasCountry() {
958    return this.country != null && !this.country.isEmpty();
959  }
960
961  /**
962   * @param value {@link #country} (Country - a nation as commonly understood or
963   *              generally accepted.). This is the underlying object with id,
964   *              value and extensions. The accessor "getCountry" gives direct
965   *              access to the value
966   */
967  public Address setCountryElement(StringType value) {
968    this.country = value;
969    return this;
970  }
971
972  /**
973   * @return Country - a nation as commonly understood or generally accepted.
974   */
975  public String getCountry() {
976    return this.country == null ? null : this.country.getValue();
977  }
978
979  /**
980   * @param value Country - a nation as commonly understood or generally accepted.
981   */
982  public Address setCountry(String value) {
983    if (Utilities.noString(value))
984      this.country = null;
985    else {
986      if (this.country == null)
987        this.country = new StringType();
988      this.country.setValue(value);
989    }
990    return this;
991  }
992
993  /**
994   * @return {@link #period} (Time period when address was/is in use.)
995   */
996  public Period getPeriod() {
997    if (this.period == null)
998      if (Configuration.errorOnAutoCreate())
999        throw new Error("Attempt to auto-create Address.period");
1000      else if (Configuration.doAutoCreate())
1001        this.period = new Period(); // cc
1002    return this.period;
1003  }
1004
1005  public boolean hasPeriod() {
1006    return this.period != null && !this.period.isEmpty();
1007  }
1008
1009  /**
1010   * @param value {@link #period} (Time period when address was/is in use.)
1011   */
1012  public Address setPeriod(Period value) {
1013    this.period = value;
1014    return this;
1015  }
1016
1017  protected void listChildren(List<Property> children) {
1018    super.listChildren(children);
1019    children.add(new Property("use", "code", "The purpose of this address.", 0, 1, use));
1020    children.add(new Property("type", "code",
1021        "Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.",
1022        0, 1, type));
1023    children.add(new Property("text", "string",
1024        "Specifies the entire address as it should be displayed e.g. on a postal label. This may be provided instead of or as well as the specific parts.",
1025        0, 1, text));
1026    children.add(new Property("line", "string",
1027        "This component contains the house number, apartment number, street name, street direction,  P.O. Box number, delivery hints, and similar address information.",
1028        0, java.lang.Integer.MAX_VALUE, line));
1029    children.add(new Property("city", "string",
1030        "The name of the city, town, suburb, village or other community or delivery center.", 0, 1, city));
1031    children.add(new Property("district", "string", "The name of the administrative area (county).", 0, 1, district));
1032    children.add(new Property("state", "string",
1033        "Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes).",
1034        0, 1, state));
1035    children.add(new Property("postalCode", "string",
1036        "A postal code designating a region defined by the postal service.", 0, 1, postalCode));
1037    children.add(new Property("country", "string", "Country - a nation as commonly understood or generally accepted.",
1038        0, 1, country));
1039    children.add(new Property("period", "Period", "Time period when address was/is in use.", 0, 1, period));
1040  }
1041
1042  @Override
1043  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1044    switch (_hash) {
1045    case 116103:
1046      /* use */ return new Property("use", "code", "The purpose of this address.", 0, 1, use);
1047    case 3575610:
1048      /* type */ return new Property("type", "code",
1049          "Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.",
1050          0, 1, type);
1051    case 3556653:
1052      /* text */ return new Property("text", "string",
1053          "Specifies the entire address as it should be displayed e.g. on a postal label. This may be provided instead of or as well as the specific parts.",
1054          0, 1, text);
1055    case 3321844:
1056      /* line */ return new Property("line", "string",
1057          "This component contains the house number, apartment number, street name, street direction,  P.O. Box number, delivery hints, and similar address information.",
1058          0, java.lang.Integer.MAX_VALUE, line);
1059    case 3053931:
1060      /* city */ return new Property("city", "string",
1061          "The name of the city, town, suburb, village or other community or delivery center.", 0, 1, city);
1062    case 288961422:
1063      /* district */ return new Property("district", "string", "The name of the administrative area (county).", 0, 1,
1064          district);
1065    case 109757585:
1066      /* state */ return new Property("state", "string",
1067          "Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes).",
1068          0, 1, state);
1069    case 2011152728:
1070      /* postalCode */ return new Property("postalCode", "string",
1071          "A postal code designating a region defined by the postal service.", 0, 1, postalCode);
1072    case 957831062:
1073      /* country */ return new Property("country", "string",
1074          "Country - a nation as commonly understood or generally accepted.", 0, 1, country);
1075    case -991726143:
1076      /* period */ return new Property("period", "Period", "Time period when address was/is in use.", 0, 1, period);
1077    default:
1078      return super.getNamedProperty(_hash, _name, _checkValid);
1079    }
1080
1081  }
1082
1083  @Override
1084  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1085    switch (hash) {
1086    case 116103:
1087      /* use */ return this.use == null ? new Base[0] : new Base[] { this.use }; // Enumeration<AddressUse>
1088    case 3575610:
1089      /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // Enumeration<AddressType>
1090    case 3556653:
1091      /* text */ return this.text == null ? new Base[0] : new Base[] { this.text }; // StringType
1092    case 3321844:
1093      /* line */ return this.line == null ? new Base[0] : this.line.toArray(new Base[this.line.size()]); // StringType
1094    case 3053931:
1095      /* city */ return this.city == null ? new Base[0] : new Base[] { this.city }; // StringType
1096    case 288961422:
1097      /* district */ return this.district == null ? new Base[0] : new Base[] { this.district }; // StringType
1098    case 109757585:
1099      /* state */ return this.state == null ? new Base[0] : new Base[] { this.state }; // StringType
1100    case 2011152728:
1101      /* postalCode */ return this.postalCode == null ? new Base[0] : new Base[] { this.postalCode }; // StringType
1102    case 957831062:
1103      /* country */ return this.country == null ? new Base[0] : new Base[] { this.country }; // StringType
1104    case -991726143:
1105      /* period */ return this.period == null ? new Base[0] : new Base[] { this.period }; // Period
1106    default:
1107      return super.getProperty(hash, name, checkValid);
1108    }
1109
1110  }
1111
1112  @Override
1113  public Base setProperty(int hash, String name, Base value) throws FHIRException {
1114    switch (hash) {
1115    case 116103: // use
1116      value = new AddressUseEnumFactory().fromType(castToCode(value));
1117      this.use = (Enumeration) value; // Enumeration<AddressUse>
1118      return value;
1119    case 3575610: // type
1120      value = new AddressTypeEnumFactory().fromType(castToCode(value));
1121      this.type = (Enumeration) value; // Enumeration<AddressType>
1122      return value;
1123    case 3556653: // text
1124      this.text = castToString(value); // StringType
1125      return value;
1126    case 3321844: // line
1127      this.getLine().add(castToString(value)); // StringType
1128      return value;
1129    case 3053931: // city
1130      this.city = castToString(value); // StringType
1131      return value;
1132    case 288961422: // district
1133      this.district = castToString(value); // StringType
1134      return value;
1135    case 109757585: // state
1136      this.state = castToString(value); // StringType
1137      return value;
1138    case 2011152728: // postalCode
1139      this.postalCode = castToString(value); // StringType
1140      return value;
1141    case 957831062: // country
1142      this.country = castToString(value); // StringType
1143      return value;
1144    case -991726143: // period
1145      this.period = castToPeriod(value); // Period
1146      return value;
1147    default:
1148      return super.setProperty(hash, name, value);
1149    }
1150
1151  }
1152
1153  @Override
1154  public Base setProperty(String name, Base value) throws FHIRException {
1155    if (name.equals("use")) {
1156      value = new AddressUseEnumFactory().fromType(castToCode(value));
1157      this.use = (Enumeration) value; // Enumeration<AddressUse>
1158    } else if (name.equals("type")) {
1159      value = new AddressTypeEnumFactory().fromType(castToCode(value));
1160      this.type = (Enumeration) value; // Enumeration<AddressType>
1161    } else if (name.equals("text")) {
1162      this.text = castToString(value); // StringType
1163    } else if (name.equals("line")) {
1164      this.getLine().add(castToString(value));
1165    } else if (name.equals("city")) {
1166      this.city = castToString(value); // StringType
1167    } else if (name.equals("district")) {
1168      this.district = castToString(value); // StringType
1169    } else if (name.equals("state")) {
1170      this.state = castToString(value); // StringType
1171    } else if (name.equals("postalCode")) {
1172      this.postalCode = castToString(value); // StringType
1173    } else if (name.equals("country")) {
1174      this.country = castToString(value); // StringType
1175    } else if (name.equals("period")) {
1176      this.period = castToPeriod(value); // Period
1177    } else
1178      return super.setProperty(name, value);
1179    return value;
1180  }
1181
1182  @Override
1183  public Base makeProperty(int hash, String name) throws FHIRException {
1184    switch (hash) {
1185    case 116103:
1186      return getUseElement();
1187    case 3575610:
1188      return getTypeElement();
1189    case 3556653:
1190      return getTextElement();
1191    case 3321844:
1192      return addLineElement();
1193    case 3053931:
1194      return getCityElement();
1195    case 288961422:
1196      return getDistrictElement();
1197    case 109757585:
1198      return getStateElement();
1199    case 2011152728:
1200      return getPostalCodeElement();
1201    case 957831062:
1202      return getCountryElement();
1203    case -991726143:
1204      return getPeriod();
1205    default:
1206      return super.makeProperty(hash, name);
1207    }
1208
1209  }
1210
1211  @Override
1212  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1213    switch (hash) {
1214    case 116103:
1215      /* use */ return new String[] { "code" };
1216    case 3575610:
1217      /* type */ return new String[] { "code" };
1218    case 3556653:
1219      /* text */ return new String[] { "string" };
1220    case 3321844:
1221      /* line */ return new String[] { "string" };
1222    case 3053931:
1223      /* city */ return new String[] { "string" };
1224    case 288961422:
1225      /* district */ return new String[] { "string" };
1226    case 109757585:
1227      /* state */ return new String[] { "string" };
1228    case 2011152728:
1229      /* postalCode */ return new String[] { "string" };
1230    case 957831062:
1231      /* country */ return new String[] { "string" };
1232    case -991726143:
1233      /* period */ return new String[] { "Period" };
1234    default:
1235      return super.getTypesForProperty(hash, name);
1236    }
1237
1238  }
1239
1240  @Override
1241  public Base addChild(String name) throws FHIRException {
1242    if (name.equals("use")) {
1243      throw new FHIRException("Cannot call addChild on a singleton property Address.use");
1244    } else if (name.equals("type")) {
1245      throw new FHIRException("Cannot call addChild on a singleton property Address.type");
1246    } else if (name.equals("text")) {
1247      throw new FHIRException("Cannot call addChild on a singleton property Address.text");
1248    } else if (name.equals("line")) {
1249      throw new FHIRException("Cannot call addChild on a singleton property Address.line");
1250    } else if (name.equals("city")) {
1251      throw new FHIRException("Cannot call addChild on a singleton property Address.city");
1252    } else if (name.equals("district")) {
1253      throw new FHIRException("Cannot call addChild on a singleton property Address.district");
1254    } else if (name.equals("state")) {
1255      throw new FHIRException("Cannot call addChild on a singleton property Address.state");
1256    } else if (name.equals("postalCode")) {
1257      throw new FHIRException("Cannot call addChild on a singleton property Address.postalCode");
1258    } else if (name.equals("country")) {
1259      throw new FHIRException("Cannot call addChild on a singleton property Address.country");
1260    } else if (name.equals("period")) {
1261      this.period = new Period();
1262      return this.period;
1263    } else
1264      return super.addChild(name);
1265  }
1266
1267  public String fhirType() {
1268    return "Address";
1269
1270  }
1271
1272  public Address copy() {
1273    Address dst = new Address();
1274    copyValues(dst);
1275    return dst;
1276  }
1277
1278  public void copyValues(Address dst) {
1279    super.copyValues(dst);
1280    dst.use = use == null ? null : use.copy();
1281    dst.type = type == null ? null : type.copy();
1282    dst.text = text == null ? null : text.copy();
1283    if (line != null) {
1284      dst.line = new ArrayList<StringType>();
1285      for (StringType i : line)
1286        dst.line.add(i.copy());
1287    }
1288    ;
1289    dst.city = city == null ? null : city.copy();
1290    dst.district = district == null ? null : district.copy();
1291    dst.state = state == null ? null : state.copy();
1292    dst.postalCode = postalCode == null ? null : postalCode.copy();
1293    dst.country = country == null ? null : country.copy();
1294    dst.period = period == null ? null : period.copy();
1295  }
1296
1297  protected Address typedCopy() {
1298    return copy();
1299  }
1300
1301  @Override
1302  public boolean equalsDeep(Base other_) {
1303    if (!super.equalsDeep(other_))
1304      return false;
1305    if (!(other_ instanceof Address))
1306      return false;
1307    Address o = (Address) other_;
1308    return compareDeep(use, o.use, true) && compareDeep(type, o.type, true) && compareDeep(text, o.text, true)
1309        && compareDeep(line, o.line, true) && compareDeep(city, o.city, true) && compareDeep(district, o.district, true)
1310        && compareDeep(state, o.state, true) && compareDeep(postalCode, o.postalCode, true)
1311        && compareDeep(country, o.country, true) && compareDeep(period, o.period, true);
1312  }
1313
1314  @Override
1315  public boolean equalsShallow(Base other_) {
1316    if (!super.equalsShallow(other_))
1317      return false;
1318    if (!(other_ instanceof Address))
1319      return false;
1320    Address o = (Address) other_;
1321    return compareValues(use, o.use, true) && compareValues(type, o.type, true) && compareValues(text, o.text, true)
1322        && compareValues(line, o.line, true) && compareValues(city, o.city, true)
1323        && compareValues(district, o.district, true) && compareValues(state, o.state, true)
1324        && compareValues(postalCode, o.postalCode, true) && compareValues(country, o.country, true);
1325  }
1326
1327  public boolean isEmpty() {
1328    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(use, type, text, line, city, district, state,
1329        postalCode, country, period);
1330  }
1331
1332}