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