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