001package org.hl7.fhir.dstu3.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 Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1 033 034import java.util.*; 035 036import java.math.*; 037import org.hl7.fhir.utilities.Utilities; 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.ChildOrder; 040import ca.uhn.fhir.model.api.annotation.Description; 041import ca.uhn.fhir.model.api.annotation.DatatypeDef; 042import ca.uhn.fhir.model.api.annotation.Block; 043import org.hl7.fhir.instance.model.api.*; 044import org.hl7.fhir.exceptions.FHIRException; 045/** 046 * 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. 047 */ 048@DatatypeDef(name="Quantity") 049public class Quantity extends Type implements ICompositeType { 050 051 public enum QuantityComparator { 052 /** 053 * The actual value is less than the given value. 054 */ 055 LESS_THAN, 056 /** 057 * The actual value is less than or equal to the given value. 058 */ 059 LESS_OR_EQUAL, 060 /** 061 * The actual value is greater than or equal to the given value. 062 */ 063 GREATER_OR_EQUAL, 064 /** 065 * The actual value is greater than the given value. 066 */ 067 GREATER_THAN, 068 /** 069 * added to help the parsers with the generic types 070 */ 071 NULL; 072 public static QuantityComparator fromCode(String codeString) throws FHIRException { 073 if (codeString == null || "".equals(codeString)) 074 return null; 075 if ("<".equals(codeString)) 076 return LESS_THAN; 077 if ("<=".equals(codeString)) 078 return LESS_OR_EQUAL; 079 if (">=".equals(codeString)) 080 return GREATER_OR_EQUAL; 081 if (">".equals(codeString)) 082 return GREATER_THAN; 083 if (Configuration.isAcceptInvalidEnums()) 084 return null; 085 else 086 throw new FHIRException("Unknown QuantityComparator code '"+codeString+"'"); 087 } 088 public String toCode() { 089 switch (this) { 090 case LESS_THAN: return "<"; 091 case LESS_OR_EQUAL: return "<="; 092 case GREATER_OR_EQUAL: return ">="; 093 case GREATER_THAN: return ">"; 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 default: return "?"; 104 } 105 } 106 public String getDefinition() { 107 switch (this) { 108 case LESS_THAN: return "The actual value is less than the given value."; 109 case LESS_OR_EQUAL: return "The actual value is less than or equal to the given value."; 110 case GREATER_OR_EQUAL: return "The actual value is greater than or equal to the given value."; 111 case GREATER_THAN: return "The actual value is greater than the given value."; 112 default: return "?"; 113 } 114 } 115 public String getDisplay() { 116 switch (this) { 117 case LESS_THAN: return "Less than"; 118 case LESS_OR_EQUAL: return "Less or Equal to"; 119 case GREATER_OR_EQUAL: return "Greater or Equal to"; 120 case GREATER_THAN: return "Greater than"; 121 default: return "?"; 122 } 123 } 124 } 125 126 public static class QuantityComparatorEnumFactory implements EnumFactory<QuantityComparator> { 127 public QuantityComparator fromCode(String codeString) throws IllegalArgumentException { 128 if (codeString == null || "".equals(codeString)) 129 if (codeString == null || "".equals(codeString)) 130 return null; 131 if ("<".equals(codeString)) 132 return QuantityComparator.LESS_THAN; 133 if ("<=".equals(codeString)) 134 return QuantityComparator.LESS_OR_EQUAL; 135 if (">=".equals(codeString)) 136 return QuantityComparator.GREATER_OR_EQUAL; 137 if (">".equals(codeString)) 138 return QuantityComparator.GREATER_THAN; 139 throw new IllegalArgumentException("Unknown QuantityComparator code '"+codeString+"'"); 140 } 141 public Enumeration<QuantityComparator> fromType(Base code) throws FHIRException { 142 if (code == null) 143 return null; 144 if (code.isEmpty()) 145 return new Enumeration<QuantityComparator>(this); 146 String codeString = ((PrimitiveType) code).asStringValue(); 147 if (codeString == null || "".equals(codeString)) 148 return null; 149 if ("<".equals(codeString)) 150 return new Enumeration<QuantityComparator>(this, QuantityComparator.LESS_THAN); 151 if ("<=".equals(codeString)) 152 return new Enumeration<QuantityComparator>(this, QuantityComparator.LESS_OR_EQUAL); 153 if (">=".equals(codeString)) 154 return new Enumeration<QuantityComparator>(this, QuantityComparator.GREATER_OR_EQUAL); 155 if (">".equals(codeString)) 156 return new Enumeration<QuantityComparator>(this, QuantityComparator.GREATER_THAN); 157 throw new FHIRException("Unknown QuantityComparator code '"+codeString+"'"); 158 } 159 public String toCode(QuantityComparator code) { 160 if (code == QuantityComparator.LESS_THAN) 161 return "<"; 162 if (code == QuantityComparator.LESS_OR_EQUAL) 163 return "<="; 164 if (code == QuantityComparator.GREATER_OR_EQUAL) 165 return ">="; 166 if (code == QuantityComparator.GREATER_THAN) 167 return ">"; 168 return "?"; 169 } 170 public String toSystem(QuantityComparator code) { 171 return code.getSystem(); 172 } 173 } 174 175 /** 176 * The value of the measured amount. The value includes an implicit precision in the presentation of the value. 177 */ 178 @Child(name = "value", type = {DecimalType.class}, order=0, min=0, max=1, modifier=false, summary=true) 179 @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." ) 180 protected DecimalType value; 181 182 /** 183 * 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. 184 */ 185 @Child(name = "comparator", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true) 186 @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." ) 187 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/quantity-comparator") 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 Base setProperty(int hash, String name, Base value) throws FHIRException { 558 switch (hash) { 559 case 111972721: // value 560 this.value = castToDecimal(value); // DecimalType 561 return value; 562 case -844673834: // comparator 563 value = new QuantityComparatorEnumFactory().fromType(castToCode(value)); 564 this.comparator = (Enumeration) value; // Enumeration<QuantityComparator> 565 return value; 566 case 3594628: // unit 567 this.unit = castToString(value); // StringType 568 return value; 569 case -887328209: // system 570 this.system = castToUri(value); // UriType 571 return value; 572 case 3059181: // code 573 this.code = castToCode(value); // CodeType 574 return value; 575 default: return super.setProperty(hash, name, value); 576 } 577 578 } 579 580 @Override 581 public Base setProperty(String name, Base value) throws FHIRException { 582 if (name.equals("value")) { 583 this.value = castToDecimal(value); // DecimalType 584 } else if (name.equals("comparator")) { 585 value = new QuantityComparatorEnumFactory().fromType(castToCode(value)); 586 this.comparator = (Enumeration) value; // Enumeration<QuantityComparator> 587 } else if (name.equals("unit")) { 588 this.unit = castToString(value); // StringType 589 } else if (name.equals("system")) { 590 this.system = castToUri(value); // UriType 591 } else if (name.equals("code")) { 592 this.code = castToCode(value); // CodeType 593 } else 594 return super.setProperty(name, value); 595 return value; 596 } 597 598 @Override 599 public Base makeProperty(int hash, String name) throws FHIRException { 600 switch (hash) { 601 case 111972721: return getValueElement(); 602 case -844673834: return getComparatorElement(); 603 case 3594628: return getUnitElement(); 604 case -887328209: return getSystemElement(); 605 case 3059181: return getCodeElement(); 606 default: return super.makeProperty(hash, name); 607 } 608 609 } 610 611 @Override 612 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 613 switch (hash) { 614 case 111972721: /*value*/ return new String[] {"decimal"}; 615 case -844673834: /*comparator*/ return new String[] {"code"}; 616 case 3594628: /*unit*/ return new String[] {"string"}; 617 case -887328209: /*system*/ return new String[] {"uri"}; 618 case 3059181: /*code*/ return new String[] {"code"}; 619 default: return super.getTypesForProperty(hash, name); 620 } 621 622 } 623 624 @Override 625 public Base addChild(String name) throws FHIRException { 626 if (name.equals("value")) { 627 throw new FHIRException("Cannot call addChild on a primitive type Quantity.value"); 628 } 629 else if (name.equals("comparator")) { 630 throw new FHIRException("Cannot call addChild on a primitive type Quantity.comparator"); 631 } 632 else if (name.equals("unit")) { 633 throw new FHIRException("Cannot call addChild on a primitive type Quantity.unit"); 634 } 635 else if (name.equals("system")) { 636 throw new FHIRException("Cannot call addChild on a primitive type Quantity.system"); 637 } 638 else if (name.equals("code")) { 639 throw new FHIRException("Cannot call addChild on a primitive type Quantity.code"); 640 } 641 else 642 return super.addChild(name); 643 } 644 645 public String fhirType() { 646 return "Quantity"; 647 648 } 649 650 public Quantity copy() { 651 Quantity dst = new Quantity(); 652 copyValues(dst); 653 dst.value = value == null ? null : value.copy(); 654 dst.comparator = comparator == null ? null : comparator.copy(); 655 dst.unit = unit == null ? null : unit.copy(); 656 dst.system = system == null ? null : system.copy(); 657 dst.code = code == null ? null : code.copy(); 658 return dst; 659 } 660 661 protected Quantity typedCopy() { 662 return copy(); 663 } 664 665 @Override 666 public boolean equalsDeep(Base other) { 667 if (!super.equalsDeep(other)) 668 return false; 669 if (!(other instanceof Quantity)) 670 return false; 671 Quantity o = (Quantity) other; 672 return compareDeep(value, o.value, true) && compareDeep(comparator, o.comparator, true) && compareDeep(unit, o.unit, true) 673 && compareDeep(system, o.system, true) && compareDeep(code, o.code, true); 674 } 675 676 @Override 677 public boolean equalsShallow(Base other) { 678 if (!super.equalsShallow(other)) 679 return false; 680 if (!(other instanceof Quantity)) 681 return false; 682 Quantity o = (Quantity) other; 683 return compareValues(value, o.value, true) && compareValues(comparator, o.comparator, true) && compareValues(unit, o.unit, true) 684 && compareValues(system, o.system, true) && compareValues(code, o.code, true); 685 } 686 687 public boolean isEmpty() { 688 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(value, comparator, unit 689 , system, code); 690 } 691 692 693} 694