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