001package org.hl7.fhir.dstu2016may.model;
002
003
004
005
006import java.math.BigDecimal;
007
008/*
009  Copyright (c) 2011+, HL7, Inc.
010  All rights reserved.
011  
012  Redistribution and use in source and binary forms, with or without modification, 
013  are permitted provided that the following conditions are met:
014  
015   * Redistributions of source code must retain the above copyright notice, this 
016     list of conditions and the following disclaimer.
017   * Redistributions in binary form must reproduce the above copyright notice, 
018     this list of conditions and the following disclaimer in the documentation 
019     and/or other materials provided with the distribution.
020   * Neither the name of HL7 nor the names of its contributors may be used to 
021     endorse or promote products derived from this software without specific 
022     prior written permission.
023  
024  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
025  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
026  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
027  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
028  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
029  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
030  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
031  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
032  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
033  POSSIBILITY OF SUCH DAMAGE.
034  
035*/
036
037// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
038import java.util.List;
039
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import org.hl7.fhir.utilities.Utilities;
043
044import ca.uhn.fhir.model.api.annotation.Child;
045import ca.uhn.fhir.model.api.annotation.DatatypeDef;
046import ca.uhn.fhir.model.api.annotation.Description;
047/**
048 * A measured amount (or an amount that can potentially be measured). Note that measured amounts include amounts that are not precisely quantified, including amounts involving arbitrary units and floating currencies.
049 */
050@DatatypeDef(name="Quantity")
051public class Quantity extends Type implements ICompositeType {
052
053    public enum QuantityComparator {
054        /**
055         * The actual value is less than the given value.
056         */
057        LESS_THAN, 
058        /**
059         * The actual value is less than or equal to the given value.
060         */
061        LESS_OR_EQUAL, 
062        /**
063         * The actual value is greater than or equal to the given value.
064         */
065        GREATER_OR_EQUAL, 
066        /**
067         * The actual value is greater than the given value.
068         */
069        GREATER_THAN, 
070        /**
071         * added to help the parsers
072         */
073        NULL;
074        public static QuantityComparator fromCode(String codeString) throws FHIRException {
075            if (codeString == null || "".equals(codeString))
076                return null;
077        if ("<".equals(codeString))
078          return LESS_THAN;
079        if ("<=".equals(codeString))
080          return LESS_OR_EQUAL;
081        if (">=".equals(codeString))
082          return GREATER_OR_EQUAL;
083        if (">".equals(codeString))
084          return GREATER_THAN;
085        throw new FHIRException("Unknown QuantityComparator code '"+codeString+"'");
086        }
087        public String toCode() {
088          switch (this) {
089            case LESS_THAN: return "<";
090            case LESS_OR_EQUAL: return "<=";
091            case GREATER_OR_EQUAL: return ">=";
092            case GREATER_THAN: return ">";
093            case NULL: return null;
094            default: return "?";
095          }
096        }
097        public String getSystem() {
098          switch (this) {
099            case LESS_THAN: return "http://hl7.org/fhir/quantity-comparator";
100            case LESS_OR_EQUAL: return "http://hl7.org/fhir/quantity-comparator";
101            case GREATER_OR_EQUAL: return "http://hl7.org/fhir/quantity-comparator";
102            case GREATER_THAN: return "http://hl7.org/fhir/quantity-comparator";
103            case NULL: return null;
104            default: return "?";
105          }
106        }
107        public String getDefinition() {
108          switch (this) {
109            case LESS_THAN: return "The actual value is less than the given value.";
110            case LESS_OR_EQUAL: return "The actual value is less than or equal to the given value.";
111            case GREATER_OR_EQUAL: return "The actual value is greater than or equal to the given value.";
112            case GREATER_THAN: return "The actual value is greater than the given value.";
113            case NULL: return null;
114            default: return "?";
115          }
116        }
117        public String getDisplay() {
118          switch (this) {
119            case LESS_THAN: return "Less than";
120            case LESS_OR_EQUAL: return "Less or Equal to";
121            case GREATER_OR_EQUAL: return "Greater or Equal to";
122            case GREATER_THAN: return "Greater than";
123            case NULL: return null;
124            default: return "?";
125          }
126        }
127    }
128
129  public static class QuantityComparatorEnumFactory implements EnumFactory<QuantityComparator> {
130    public QuantityComparator fromCode(String codeString) throws IllegalArgumentException {
131      if (codeString == null || "".equals(codeString))
132            if (codeString == null || "".equals(codeString))
133                return null;
134        if ("<".equals(codeString))
135          return QuantityComparator.LESS_THAN;
136        if ("<=".equals(codeString))
137          return QuantityComparator.LESS_OR_EQUAL;
138        if (">=".equals(codeString))
139          return QuantityComparator.GREATER_OR_EQUAL;
140        if (">".equals(codeString))
141          return QuantityComparator.GREATER_THAN;
142        throw new IllegalArgumentException("Unknown QuantityComparator code '"+codeString+"'");
143        }
144        public Enumeration<QuantityComparator> fromType(Base code) throws FHIRException {
145          if (code == null || code.isEmpty())
146            return null;
147          String codeString = ((PrimitiveType) code).asStringValue();
148          if (codeString == null || "".equals(codeString))
149            return null;
150        if ("<".equals(codeString))
151          return new Enumeration<QuantityComparator>(this, QuantityComparator.LESS_THAN);
152        if ("<=".equals(codeString))
153          return new Enumeration<QuantityComparator>(this, QuantityComparator.LESS_OR_EQUAL);
154        if (">=".equals(codeString))
155          return new Enumeration<QuantityComparator>(this, QuantityComparator.GREATER_OR_EQUAL);
156        if (">".equals(codeString))
157          return new Enumeration<QuantityComparator>(this, QuantityComparator.GREATER_THAN);
158        throw new FHIRException("Unknown QuantityComparator code '"+codeString+"'");
159        }
160    public String toCode(QuantityComparator code) {
161      if (code == QuantityComparator.LESS_THAN)
162        return "<";
163      if (code == QuantityComparator.LESS_OR_EQUAL)
164        return "<=";
165      if (code == QuantityComparator.GREATER_OR_EQUAL)
166        return ">=";
167      if (code == QuantityComparator.GREATER_THAN)
168        return ">";
169      return "?";
170      }
171    public String toSystem(QuantityComparator code) {
172      return code.getSystem();
173      }
174    }
175
176    /**
177     * The value of the measured amount. The value includes an implicit precision in the presentation of the value.
178     */
179    @Child(name = "value", type = {DecimalType.class}, order=0, min=0, max=1, modifier=false, summary=true)
180    @Description(shortDefinition="Numerical value (with implicit precision)", formalDefinition="The value of the measured amount. The value includes an implicit precision in the presentation of the value." )
181    protected DecimalType value;
182
183    /**
184     * How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.
185     */
186    @Child(name = "comparator", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
187    @Description(shortDefinition="< | <= | >= | > - how to understand the value", formalDefinition="How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \"<\" , then the real value is < stated value." )
188    protected Enumeration<QuantityComparator> comparator;
189
190    /**
191     * A human-readable form of the unit.
192     */
193    @Child(name = "unit", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
194    @Description(shortDefinition="Unit representation", formalDefinition="A human-readable form of the unit." )
195    protected StringType unit;
196
197    /**
198     * The identification of the system that provides the coded form of the unit.
199     */
200    @Child(name = "system", type = {UriType.class}, order=3, min=0, max=1, modifier=false, summary=true)
201    @Description(shortDefinition="System that defines coded unit form", formalDefinition="The identification of the system that provides the coded form of the unit." )
202    protected UriType system;
203
204    /**
205     * A computer processable form of the unit in some unit representation system.
206     */
207    @Child(name = "code", type = {CodeType.class}, order=4, min=0, max=1, modifier=false, summary=true)
208    @Description(shortDefinition="Coded form of the unit", formalDefinition="A computer processable form of the unit in some unit representation system." )
209    protected CodeType code;
210
211    private static final long serialVersionUID = 1069574054L;
212
213  /**
214   * Constructor
215   */
216    public Quantity() {
217      super();
218    }
219
220 /**
221   * Convenience constructor
222   * 
223   * @param theValue The {@link #setValue(double) value}
224   */
225  public Quantity(double theValue) {
226    setValue(theValue);
227  }
228
229  /**
230   * Convenience constructor
231   * 
232   * @param theValue The {@link #setValue(long) value}
233   */
234  public Quantity(long theValue) {
235    setValue(theValue);
236  }
237  
238  /**
239   * Convenience constructor
240   * 
241   * @param theComparator The {@link #setComparator(QuantityComparator) comparator}
242   * @param theValue The {@link #setValue(BigDecimal) value}
243   * @param theSystem The {@link #setSystem(String)} (the code system for the units}
244   * @param theCode The {@link #setCode(String)} (the code for the units}
245   * @param theUnit The {@link #setUnit(String)} (the human readable display name for the units}
246   */
247  public Quantity(QuantityComparator theComparator, double theValue, String theSystem, String theCode, String theUnit) {
248    setValue(theValue);
249    setComparator(theComparator);
250    setSystem(theSystem);
251    setCode(theCode);
252    setUnit(theUnit);
253  }
254
255  /**
256   * Convenience constructor
257   * 
258   * @param theComparator The {@link #setComparator(QuantityComparator) comparator}
259   * @param theValue The {@link #setValue(BigDecimal) value}
260   * @param theSystem The {@link #setSystem(String)} (the code system for the units}
261   * @param theCode The {@link #setCode(String)} (the code for the units}
262   * @param theUnit The {@link #setUnit(String)} (the human readable display name for the units}
263   */
264  public Quantity(QuantityComparator theComparator, long theValue, String theSystem, String theCode, String theUnit) {
265    setValue(theValue);
266    setComparator(theComparator);
267    setSystem(theSystem);
268    setCode(theCode);
269    setUnit(theUnit);
270  }
271    /**
272     * @return {@link #value} (The value of the measured amount. The value includes an implicit precision in the presentation of the value.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
273     */
274    public DecimalType getValueElement() { 
275      if (this.value == null)
276        if (Configuration.errorOnAutoCreate())
277          throw new Error("Attempt to auto-create Quantity.value");
278        else if (Configuration.doAutoCreate())
279          this.value = new DecimalType(); // bb
280      return this.value;
281    }
282
283    public boolean hasValueElement() { 
284      return this.value != null && !this.value.isEmpty();
285    }
286
287    public boolean hasValue() { 
288      return this.value != null && !this.value.isEmpty();
289    }
290
291    /**
292     * @param value {@link #value} (The value of the measured amount. The value includes an implicit precision in the presentation of the value.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
293     */
294    public Quantity setValueElement(DecimalType value) { 
295      this.value = value;
296      return this;
297    }
298
299    /**
300     * @return The value of the measured amount. The value includes an implicit precision in the presentation of the value.
301     */
302    public BigDecimal getValue() { 
303      return this.value == null ? null : this.value.getValue();
304    }
305
306    /**
307     * @param value The value of the measured amount. The value includes an implicit precision in the presentation of the value.
308     */
309    public Quantity setValue(BigDecimal value) { 
310      if (value == null)
311        this.value = null;
312      else {
313        if (this.value == null)
314          this.value = new DecimalType();
315        this.value.setValue(value);
316      }
317      return this;
318    }
319
320    /**
321     * @param value The value of the measured amount. The value includes an implicit precision in the presentation of the value.
322     */
323    public Quantity setValue(long value) { 
324          this.value = new DecimalType();
325        this.value.setValue(value);
326      return this;
327    }
328
329    /**
330     * @param value The value of the measured amount. The value includes an implicit precision in the presentation of the value.
331     */
332    public Quantity setValue(double value) { 
333          this.value = new DecimalType();
334        this.value.setValue(value);
335      return this;
336    }
337
338    /**
339     * @return {@link #comparator} (How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.). This is the underlying object with id, value and extensions. The accessor "getComparator" gives direct access to the value
340     */
341    public Enumeration<QuantityComparator> getComparatorElement() { 
342      if (this.comparator == null)
343        if (Configuration.errorOnAutoCreate())
344          throw new Error("Attempt to auto-create Quantity.comparator");
345        else if (Configuration.doAutoCreate())
346          this.comparator = new Enumeration<QuantityComparator>(new QuantityComparatorEnumFactory()); // bb
347      return this.comparator;
348    }
349
350    public boolean hasComparatorElement() { 
351      return this.comparator != null && !this.comparator.isEmpty();
352    }
353
354    public boolean hasComparator() { 
355      return this.comparator != null && !this.comparator.isEmpty();
356    }
357
358    /**
359     * @param value {@link #comparator} (How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.). This is the underlying object with id, value and extensions. The accessor "getComparator" gives direct access to the value
360     */
361    public Quantity setComparatorElement(Enumeration<QuantityComparator> value) { 
362      this.comparator = value;
363      return this;
364    }
365
366    /**
367     * @return How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.
368     */
369    public QuantityComparator getComparator() { 
370      return this.comparator == null ? null : this.comparator.getValue();
371    }
372
373    /**
374     * @param value How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.
375     */
376    public Quantity setComparator(QuantityComparator value) { 
377      if (value == null)
378        this.comparator = null;
379      else {
380        if (this.comparator == null)
381          this.comparator = new Enumeration<QuantityComparator>(new QuantityComparatorEnumFactory());
382        this.comparator.setValue(value);
383      }
384      return this;
385    }
386
387    /**
388     * @return {@link #unit} (A human-readable form of the unit.). This is the underlying object with id, value and extensions. The accessor "getUnit" gives direct access to the value
389     */
390    public StringType getUnitElement() { 
391      if (this.unit == null)
392        if (Configuration.errorOnAutoCreate())
393          throw new Error("Attempt to auto-create Quantity.unit");
394        else if (Configuration.doAutoCreate())
395          this.unit = new StringType(); // bb
396      return this.unit;
397    }
398
399    public boolean hasUnitElement() { 
400      return this.unit != null && !this.unit.isEmpty();
401    }
402
403    public boolean hasUnit() { 
404      return this.unit != null && !this.unit.isEmpty();
405    }
406
407    /**
408     * @param value {@link #unit} (A human-readable form of the unit.). This is the underlying object with id, value and extensions. The accessor "getUnit" gives direct access to the value
409     */
410    public Quantity setUnitElement(StringType value) { 
411      this.unit = value;
412      return this;
413    }
414
415    /**
416     * @return A human-readable form of the unit.
417     */
418    public String getUnit() { 
419      return this.unit == null ? null : this.unit.getValue();
420    }
421
422    /**
423     * @param value A human-readable form of the unit.
424     */
425    public Quantity setUnit(String value) { 
426      if (Utilities.noString(value))
427        this.unit = null;
428      else {
429        if (this.unit == null)
430          this.unit = new StringType();
431        this.unit.setValue(value);
432      }
433      return this;
434    }
435
436    /**
437     * @return {@link #system} (The identification of the system that provides the coded form of the unit.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value
438     */
439    public UriType getSystemElement() { 
440      if (this.system == null)
441        if (Configuration.errorOnAutoCreate())
442          throw new Error("Attempt to auto-create Quantity.system");
443        else if (Configuration.doAutoCreate())
444          this.system = new UriType(); // bb
445      return this.system;
446    }
447
448    public boolean hasSystemElement() { 
449      return this.system != null && !this.system.isEmpty();
450    }
451
452    public boolean hasSystem() { 
453      return this.system != null && !this.system.isEmpty();
454    }
455
456    /**
457     * @param value {@link #system} (The identification of the system that provides the coded form of the unit.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value
458     */
459    public Quantity setSystemElement(UriType value) { 
460      this.system = value;
461      return this;
462    }
463
464    /**
465     * @return The identification of the system that provides the coded form of the unit.
466     */
467    public String getSystem() { 
468      return this.system == null ? null : this.system.getValue();
469    }
470
471    /**
472     * @param value The identification of the system that provides the coded form of the unit.
473     */
474    public Quantity setSystem(String value) { 
475      if (Utilities.noString(value))
476        this.system = null;
477      else {
478        if (this.system == null)
479          this.system = new UriType();
480        this.system.setValue(value);
481      }
482      return this;
483    }
484
485    /**
486     * @return {@link #code} (A computer processable form of the unit in some unit representation system.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
487     */
488    public CodeType getCodeElement() { 
489      if (this.code == null)
490        if (Configuration.errorOnAutoCreate())
491          throw new Error("Attempt to auto-create Quantity.code");
492        else if (Configuration.doAutoCreate())
493          this.code = new CodeType(); // bb
494      return this.code;
495    }
496
497    public boolean hasCodeElement() { 
498      return this.code != null && !this.code.isEmpty();
499    }
500
501    public boolean hasCode() { 
502      return this.code != null && !this.code.isEmpty();
503    }
504
505    /**
506     * @param value {@link #code} (A computer processable form of the unit in some unit representation system.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
507     */
508    public Quantity setCodeElement(CodeType value) { 
509      this.code = value;
510      return this;
511    }
512
513    /**
514     * @return A computer processable form of the unit in some unit representation system.
515     */
516    public String getCode() { 
517      return this.code == null ? null : this.code.getValue();
518    }
519
520    /**
521     * @param value A computer processable form of the unit in some unit representation system.
522     */
523    public Quantity setCode(String value) { 
524      if (Utilities.noString(value))
525        this.code = null;
526      else {
527        if (this.code == null)
528          this.code = new CodeType();
529        this.code.setValue(value);
530      }
531      return this;
532    }
533
534      protected void listChildren(List<Property> childrenList) {
535        super.listChildren(childrenList);
536        childrenList.add(new Property("value", "decimal", "The value of the measured amount. The value includes an implicit precision in the presentation of the value.", 0, java.lang.Integer.MAX_VALUE, value));
537        childrenList.add(new Property("comparator", "code", "How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \"<\" , then the real value is < stated value.", 0, java.lang.Integer.MAX_VALUE, comparator));
538        childrenList.add(new Property("unit", "string", "A human-readable form of the unit.", 0, java.lang.Integer.MAX_VALUE, unit));
539        childrenList.add(new Property("system", "uri", "The identification of the system that provides the coded form of the unit.", 0, java.lang.Integer.MAX_VALUE, system));
540        childrenList.add(new Property("code", "code", "A computer processable form of the unit in some unit representation system.", 0, java.lang.Integer.MAX_VALUE, code));
541      }
542
543      @Override
544      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
545        switch (hash) {
546        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DecimalType
547        case -844673834: /*comparator*/ return this.comparator == null ? new Base[0] : new Base[] {this.comparator}; // Enumeration<QuantityComparator>
548        case 3594628: /*unit*/ return this.unit == null ? new Base[0] : new Base[] {this.unit}; // StringType
549        case -887328209: /*system*/ return this.system == null ? new Base[0] : new Base[] {this.system}; // UriType
550        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeType
551        default: return super.getProperty(hash, name, checkValid);
552        }
553
554      }
555
556      @Override
557      public void setProperty(int hash, String name, Base value) throws FHIRException {
558        switch (hash) {
559        case 111972721: // value
560          this.value = castToDecimal(value); // DecimalType
561          break;
562        case -844673834: // comparator
563          this.comparator = new QuantityComparatorEnumFactory().fromType(value); // Enumeration<QuantityComparator>
564          break;
565        case 3594628: // unit
566          this.unit = castToString(value); // StringType
567          break;
568        case -887328209: // system
569          this.system = castToUri(value); // UriType
570          break;
571        case 3059181: // code
572          this.code = castToCode(value); // CodeType
573          break;
574        default: super.setProperty(hash, name, value);
575        }
576
577      }
578
579      @Override
580      public void setProperty(String name, Base value) throws FHIRException {
581        if (name.equals("value"))
582          this.value = castToDecimal(value); // DecimalType
583        else if (name.equals("comparator"))
584          this.comparator = new QuantityComparatorEnumFactory().fromType(value); // Enumeration<QuantityComparator>
585        else if (name.equals("unit"))
586          this.unit = castToString(value); // StringType
587        else if (name.equals("system"))
588          this.system = castToUri(value); // UriType
589        else if (name.equals("code"))
590          this.code = castToCode(value); // CodeType
591        else
592          super.setProperty(name, value);
593      }
594
595      @Override
596      public Base makeProperty(int hash, String name) throws FHIRException {
597        switch (hash) {
598        case 111972721: throw new FHIRException("Cannot make property value as it is not a complex type"); // DecimalType
599        case -844673834: throw new FHIRException("Cannot make property comparator as it is not a complex type"); // Enumeration<QuantityComparator>
600        case 3594628: throw new FHIRException("Cannot make property unit as it is not a complex type"); // StringType
601        case -887328209: throw new FHIRException("Cannot make property system as it is not a complex type"); // UriType
602        case 3059181: throw new FHIRException("Cannot make property code as it is not a complex type"); // CodeType
603        default: return super.makeProperty(hash, name);
604        }
605
606      }
607
608      @Override
609      public Base addChild(String name) throws FHIRException {
610        if (name.equals("value")) {
611          throw new FHIRException("Cannot call addChild on a primitive type Quantity.value");
612        }
613        else if (name.equals("comparator")) {
614          throw new FHIRException("Cannot call addChild on a primitive type Quantity.comparator");
615        }
616        else if (name.equals("unit")) {
617          throw new FHIRException("Cannot call addChild on a primitive type Quantity.unit");
618        }
619        else if (name.equals("system")) {
620          throw new FHIRException("Cannot call addChild on a primitive type Quantity.system");
621        }
622        else if (name.equals("code")) {
623          throw new FHIRException("Cannot call addChild on a primitive type Quantity.code");
624        }
625        else
626          return super.addChild(name);
627      }
628
629  public String fhirType() {
630    return "Quantity";
631
632  }
633
634      public Quantity copy() {
635        Quantity dst = new Quantity();
636        copyValues(dst);
637        dst.value = value == null ? null : value.copy();
638        dst.comparator = comparator == null ? null : comparator.copy();
639        dst.unit = unit == null ? null : unit.copy();
640        dst.system = system == null ? null : system.copy();
641        dst.code = code == null ? null : code.copy();
642        return dst;
643      }
644
645      protected Quantity typedCopy() {
646        return copy();
647      }
648
649      @Override
650      public boolean equalsDeep(Base other) {
651        if (!super.equalsDeep(other))
652          return false;
653        if (!(other instanceof Quantity))
654          return false;
655        Quantity o = (Quantity) other;
656        return compareDeep(value, o.value, true) && compareDeep(comparator, o.comparator, true) && compareDeep(unit, o.unit, true)
657           && compareDeep(system, o.system, true) && compareDeep(code, o.code, true);
658      }
659
660      @Override
661      public boolean equalsShallow(Base other) {
662        if (!super.equalsShallow(other))
663          return false;
664        if (!(other instanceof Quantity))
665          return false;
666        Quantity o = (Quantity) other;
667        return compareValues(value, o.value, true) && compareValues(comparator, o.comparator, true) && compareValues(unit, o.unit, true)
668           && compareValues(system, o.system, true) && compareValues(code, o.code, true);
669      }
670
671      public boolean isEmpty() {
672        return super.isEmpty() && (value == null || value.isEmpty()) && (comparator == null || comparator.isEmpty())
673           && (unit == null || unit.isEmpty()) && (system == null || system.isEmpty()) && (code == null || code.isEmpty())
674          ;
675      }
676
677
678}