
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 033 034import java.io.IOException; 035import java.io.Serializable; 036import java.util.ArrayList; 037import java.util.HashMap; 038import java.util.List; 039import java.util.Map; 040 041import org.hl7.fhir.exceptions.FHIRException; 042import org.hl7.fhir.instance.model.api.IBase; 043import org.hl7.fhir.utilities.Utilities; 044import org.hl7.fhir.utilities.xhtml.XhtmlNode; 045import org.hl7.fhir.utilities.xhtml.XhtmlParser; 046 047import ca.uhn.fhir.model.api.IElement; 048 049public abstract class Base implements Serializable, IBase, IElement { 050 051 /** 052 * User appended data items - allow users to add extra information to the class 053 */ 054private Map<String, Object> userData; 055 056 /** 057 * Round tracking xml comments for testing convenience 058 */ 059 private List<String> formatCommentsPre; 060 061 /** 062 * Round tracking xml comments for testing convenience 063 */ 064 private List<String> formatCommentsPost; 065 066 067 public Object getUserData(String name) { 068 if (userData == null) 069 return null; 070 return userData.get(name); 071 } 072 073 public void setUserData(String name, Object value) { 074 if (userData == null) 075 userData = new HashMap<String, Object>(); 076 userData.put(name, value); 077 } 078 079 public void clearUserData(String name) { 080 if (userData != null) 081 userData.remove(name); 082 } 083 084 public void setUserDataINN(String name, Object value) { 085 if (value == null) 086 return; 087 088 if (userData == null) 089 userData = new HashMap<String, Object>(); 090 userData.put(name, value); 091 } 092 093 public boolean hasUserData(String name) { 094 if (userData == null) 095 return false; 096 else 097 return userData.containsKey(name); 098 } 099 100 public String getUserString(String name) { 101 Object ud = getUserData(name); 102 if (ud == null) 103 return null; 104 if (ud instanceof String) 105 return (String) ud; 106 return ud.toString(); 107 } 108 109 public int getUserInt(String name) { 110 if (!hasUserData(name)) 111 return 0; 112 return (Integer) getUserData(name); 113 } 114 115 public boolean hasFormatComment() { 116 return (formatCommentsPre != null && !formatCommentsPre.isEmpty()) || (formatCommentsPost != null && !formatCommentsPost.isEmpty()); 117 } 118 119 public List<String> getFormatCommentsPre() { 120 if (formatCommentsPre == null) 121 formatCommentsPre = new ArrayList<String>(); 122 return formatCommentsPre; 123 } 124 125 public List<String> getFormatCommentsPost() { 126 if (formatCommentsPost == null) 127 formatCommentsPost = new ArrayList<String>(); 128 return formatCommentsPost; 129 } 130 131 // these 3 allow evaluation engines to get access to primitive values 132 public boolean isPrimitive() { 133 return false; 134 } 135 136 public boolean isBooleanPrimitive() { 137 return false; 138 } 139 140 public boolean hasPrimitiveValue() { 141 return isPrimitive(); 142 } 143 144 public String primitiveValue() { 145 return null; 146 } 147 148 public abstract String fhirType() ; 149 150 public boolean hasType(String... name) { 151 String t = fhirType(); 152 for (String n : name) 153 if (n.equalsIgnoreCase(t)) 154 return true; 155 return false; 156 } 157 158 protected abstract void listChildren(List<Property> result) ; 159 160 public Base setProperty(String name, Base value) throws FHIRException { 161 throw new FHIRException("Attempt to set unknown property "+name); 162 } 163 164 public Base addChild(String name) throws FHIRException { 165 throw new FHIRException("Attempt to add child with unknown name "+name); 166 } 167 168 /** 169 * Supports iterating the children elements in some generic processor or browser 170 * All defined children will be listed, even if they have no value on this instance 171 * 172 * Note that the actual content of primitive or xhtml elements is not iterated explicitly. 173 * To find these, the processing code must recognise the element as a primitive, typecast 174 * the value to a {@link Type}, and examine the value 175 * 176 * @return a list of all the children defined for this element 177 */ 178 public List<Property> children() { 179 List<Property> result = new ArrayList<Property>(); 180 listChildren(result); 181 return result; 182 } 183 184 public Property getChildByName(String name) { 185 List<Property> children = new ArrayList<Property>(); 186 listChildren(children); 187 for (Property c : children) 188 if (c.getName().equals(name)) 189 return c; 190 return null; 191 } 192 193 public List<Base> listChildrenByName(String name) throws FHIRException { 194 List<Base> result = new ArrayList<Base>(); 195 for (Base b : listChildrenByName(name, true)) 196 if (b != null) 197 result.add(b); 198 return result; 199 } 200 201 public Base[] listChildrenByName(String name, boolean checkValid) throws FHIRException { 202 if (name.equals("*")) { 203 List<Property> children = new ArrayList<Property>(); 204 listChildren(children); 205 List<Base> result = new ArrayList<Base>(); 206 for (Property c : children) 207 result.addAll(c.getValues()); 208 return result.toArray(new Base[result.size()]); 209 } 210 else 211 return getProperty(name.hashCode(), name, checkValid); 212 } 213 214 public boolean isEmpty() { 215 return true; // userData does not count 216 } 217 218 public boolean equalsDeep(Base other) { 219 return other != null; 220 } 221 222 public boolean equalsShallow(Base other) { 223 return other != null; 224 } 225 226 public static boolean compareDeep(List<? extends Base> e1, List<? extends Base> e2, boolean allowNull) { 227 if (noList(e1) && noList(e2) && allowNull) 228 return true; 229 if (noList(e1) || noList(e2)) 230 return false; 231 if (e1.size() != e2.size()) 232 return false; 233 for (int i = 0; i < e1.size(); i++) { 234 if (!compareDeep(e1.get(i), e2.get(i), allowNull)) 235 return false; 236 } 237 return true; 238 } 239 240 private static boolean noList(List<? extends Base> list) { 241 return list == null || list.isEmpty(); 242 } 243 244 public static boolean compareDeep(Base e1, Base e2, boolean allowNull) { 245 if (allowNull) { 246 boolean noLeft = e1 == null || e1.isEmpty(); 247 boolean noRight = e2 == null || e2.isEmpty(); 248 if (noLeft && noRight) { 249 return true; 250 } 251 } 252 if (e1 == null || e2 == null) 253 return false; 254 else 255 return e1.equalsDeep(e2); 256 } 257 258 public static boolean compareDeep(XhtmlNode div1, XhtmlNode div2, boolean allowNull) { 259 if (div1 == null && div2 == null && allowNull) 260 return true; 261 if (div1 == null || div2 == null) 262 return false; 263 return div1.equalsDeep(div2); 264 } 265 266 267 public static boolean compareValues(List<? extends PrimitiveType> e1, List<? extends PrimitiveType> e2, boolean allowNull) { 268 if (e1 == null && e2 == null && allowNull) 269 return true; 270 if (e1 == null || e2 == null) 271 return false; 272 if (e1.size() != e2.size()) 273 return false; 274 for (int i = 0; i < e1.size(); i++) { 275 if (!compareValues(e1.get(i), e2.get(i), allowNull)) 276 return false; 277 } 278 return true; 279 } 280 281 public static boolean compareValues(PrimitiveType e1, PrimitiveType e2, boolean allowNull) { 282 boolean noLeft = e1 == null || e1.isEmpty(); 283 boolean noRight = e2 == null || e2.isEmpty(); 284 if (noLeft && noRight && allowNull) { 285 return true; 286 } 287 if (noLeft != noRight) 288 return false; 289 return e1.equalsShallow(e2); 290 } 291 292 // -- converters for property setters 293 294 public Type castToType(Base b) throws FHIRException { 295 if (b instanceof Type) 296 return (Type) b; 297 else 298 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Reference"); 299 } 300 301 302 public BooleanType castToBoolean(Base b) throws FHIRException { 303 if (b instanceof BooleanType) 304 return (BooleanType) b; 305 else 306 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Boolean"); 307 } 308 309 public IntegerType castToInteger(Base b) throws FHIRException { 310 if (b instanceof IntegerType) 311 return (IntegerType) b; 312 else 313 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Integer"); 314 } 315 316 public DecimalType castToDecimal(Base b) throws FHIRException { 317 if (b instanceof DecimalType) 318 return (DecimalType) b; 319 else 320 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Decimal"); 321 } 322 323 public Base64BinaryType castToBase64Binary(Base b) throws FHIRException { 324 if (b instanceof Base64BinaryType) 325 return (Base64BinaryType) b; 326 else 327 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Base64Binary"); 328 } 329 330 public InstantType castToInstant(Base b) throws FHIRException { 331 if (b instanceof InstantType) 332 return (InstantType) b; 333 else 334 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Instant"); 335 } 336 337 public StringType castToString(Base b) throws FHIRException { 338 if (b instanceof StringType) 339 return (StringType) b; 340 else if (b.hasPrimitiveValue()) 341 return new StringType(b.primitiveValue()); 342 else 343 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a String"); 344 } 345 346 public UriType castToUri(Base b) throws FHIRException { 347 if (b instanceof UriType) 348 return (UriType) b; 349 else if (b.hasPrimitiveValue()) 350 return new UriType(b.primitiveValue()); 351 else 352 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Uri"); 353 } 354 355 public DateType castToDate(Base b) throws FHIRException { 356 if (b instanceof DateType) 357 return (DateType) b; 358 else if (b.hasPrimitiveValue()) 359 return new DateType(b.primitiveValue()); 360 else 361 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Date"); 362 } 363 364 public DateTimeType castToDateTime(Base b) throws FHIRException { 365 if (b instanceof DateTimeType) 366 return (DateTimeType) b; 367 else if (b.fhirType().equals("dateTime")) 368 return new DateTimeType(b.primitiveValue()); 369 else 370 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a DateTime"); 371 } 372 373 public TimeType castToTime(Base b) throws FHIRException { 374 if (b instanceof TimeType) 375 return (TimeType) b; 376 else 377 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Time"); 378 } 379 380 public CodeType castToCode(Base b) throws FHIRException { 381 if (b instanceof CodeType) 382 return (CodeType) b; 383 else if (b.isPrimitive()) 384 return new CodeType(b.primitiveValue()); 385 else 386 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Code"); 387 } 388 389 public OidType castToOid(Base b) throws FHIRException { 390 if (b instanceof OidType) 391 return (OidType) b; 392 else 393 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Oid"); 394 } 395 396 public IdType castToId(Base b) throws FHIRException { 397 if (b instanceof IdType) 398 return (IdType) b; 399 else 400 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Id"); 401 } 402 403 public UnsignedIntType castToUnsignedInt(Base b) throws FHIRException { 404 if (b instanceof UnsignedIntType) 405 return (UnsignedIntType) b; 406 else 407 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a UnsignedInt"); 408 } 409 410 public PositiveIntType castToPositiveInt(Base b) throws FHIRException { 411 if (b instanceof PositiveIntType) 412 return (PositiveIntType) b; 413 else 414 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a PositiveInt"); 415 } 416 417 public MarkdownType castToMarkdown(Base b) throws FHIRException { 418 if (b instanceof MarkdownType) 419 return (MarkdownType) b; 420 else 421 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Markdown"); 422 } 423 424 public Annotation castToAnnotation(Base b) throws FHIRException { 425 if (b instanceof Annotation) 426 return (Annotation) b; 427 else 428 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Annotation"); 429 } 430 431 public Dosage castToDosage(Base b) throws FHIRException { 432 if (b instanceof Dosage) 433 return (Dosage) b; 434 else throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an DosageInstruction"); 435 } 436 437 438 public Attachment castToAttachment(Base b) throws FHIRException { 439 if (b instanceof Attachment) 440 return (Attachment) b; 441 else 442 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Attachment"); 443 } 444 445 public Identifier castToIdentifier(Base b) throws FHIRException { 446 if (b instanceof Identifier) 447 return (Identifier) b; 448 else 449 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Identifier"); 450 } 451 452 public CodeableConcept castToCodeableConcept(Base b) throws FHIRException { 453 if (b instanceof CodeableConcept) 454 return (CodeableConcept) b; 455 else if (b instanceof CodeType) { 456 CodeableConcept cc = new CodeableConcept(); 457 cc.addCoding().setCode(((CodeType) b).asStringValue()); 458 return cc; 459 } else 460 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a CodeableConcept"); 461 } 462 463 public Coding castToCoding(Base b) throws FHIRException { 464 if (b instanceof Coding) 465 return (Coding) b; 466 else 467 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Coding"); 468 } 469 470 public Quantity castToQuantity(Base b) throws FHIRException { 471 if (b instanceof Quantity) 472 return (Quantity) b; 473 else 474 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Quantity"); 475 } 476 477 public Money castToMoney(Base b) throws FHIRException { 478 if (b instanceof Money) 479 return (Money) b; 480 else 481 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Money"); 482 } 483 484 public Duration castToDuration(Base b) throws FHIRException { 485 if (b instanceof Duration) 486 return (Duration) b; 487 else 488 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Duration"); 489 } 490 491 public SimpleQuantity castToSimpleQuantity(Base b) throws FHIRException { 492 if (b instanceof SimpleQuantity) 493 return (SimpleQuantity) b; 494 else if (b instanceof Quantity) { 495 Quantity q = (Quantity) b; 496 SimpleQuantity sq = new SimpleQuantity(); 497 sq.setValueElement(q.getValueElement()); 498 sq.setComparatorElement(q.getComparatorElement()); 499 sq.setUnitElement(q.getUnitElement()); 500 sq.setSystemElement(q.getSystemElement()); 501 sq.setCodeElement(q.getCodeElement()); 502 return sq; 503 } else 504 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an SimpleQuantity"); 505 } 506 507 public Range castToRange(Base b) throws FHIRException { 508 if (b instanceof Range) 509 return (Range) b; 510 else 511 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Range"); 512 } 513 514 public Period castToPeriod(Base b) throws FHIRException { 515 if (b instanceof Period) 516 return (Period) b; 517 else 518 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Period"); 519 } 520 521 public Ratio castToRatio(Base b) throws FHIRException { 522 if (b instanceof Ratio) 523 return (Ratio) b; 524 else 525 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Ratio"); 526 } 527 528 public SampledData castToSampledData(Base b) throws FHIRException { 529 if (b instanceof SampledData) 530 return (SampledData) b; 531 else 532 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a SampledData"); 533 } 534 535 public Signature castToSignature(Base b) throws FHIRException { 536 if (b instanceof Signature) 537 return (Signature) b; 538 else 539 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Signature"); 540 } 541 542 public HumanName castToHumanName(Base b) throws FHIRException { 543 if (b instanceof HumanName) 544 return (HumanName) b; 545 else 546 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a HumanName"); 547 } 548 549 public Address castToAddress(Base b) throws FHIRException { 550 if (b instanceof Address) 551 return (Address) b; 552 else 553 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Address"); 554 } 555 556 public ContactDetail castToContactDetail(Base b) throws FHIRException { 557 if (b instanceof ContactDetail) 558 return (ContactDetail) b; 559 else 560 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ContactDetail"); 561 } 562 563 public Contributor castToContributor(Base b) throws FHIRException { 564 if (b instanceof Contributor) 565 return (Contributor) b; 566 else 567 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Contributor"); 568 } 569 570 public UsageContext castToUsageContext(Base b) throws FHIRException { 571 if (b instanceof UsageContext) 572 return (UsageContext) b; 573 else 574 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a UsageContext"); 575 } 576 577 public RelatedArtifact castToRelatedArtifact(Base b) throws FHIRException { 578 if (b instanceof RelatedArtifact) 579 return (RelatedArtifact) b; 580 else 581 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a RelatedArtifact"); 582 } 583 584 public ContactPoint castToContactPoint(Base b) throws FHIRException { 585 if (b instanceof ContactPoint) 586 return (ContactPoint) b; 587 else 588 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ContactPoint"); 589 } 590 591 public Timing castToTiming(Base b) throws FHIRException { 592 if (b instanceof Timing) 593 return (Timing) b; 594 else 595 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Timing"); 596 } 597 598 public Reference castToReference(Base b) throws FHIRException { 599 if (b instanceof Reference) 600 return (Reference) b; 601 else if (b.isPrimitive() && Utilities.isURL(b.primitiveValue())) 602 return new Reference().setReference(b.primitiveValue()); 603 else 604 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Reference"); 605 } 606 607 public Meta castToMeta(Base b) throws FHIRException { 608 if (b instanceof Meta) 609 return (Meta) b; 610 else 611 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Meta"); 612 } 613 614 public Extension castToExtension(Base b) throws FHIRException { 615 if (b instanceof Extension) 616 return (Extension) b; 617 else 618 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Extension"); 619 } 620 621 public Resource castToResource(Base b) throws FHIRException { 622 if (b instanceof Resource) 623 return (Resource) b; 624 else 625 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Resource"); 626 } 627 628 public Narrative castToNarrative(Base b) throws FHIRException { 629 if (b instanceof Narrative) 630 return (Narrative) b; 631 else 632 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Narrative"); 633 } 634 635 636 public ElementDefinition castToElementDefinition(Base b) throws FHIRException { 637 if (b instanceof ElementDefinition) 638 return (ElementDefinition) b; 639 else 640 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ElementDefinition"); 641 } 642 643 public DataRequirement castToDataRequirement(Base b) throws FHIRException { 644 if (b instanceof DataRequirement) 645 return (DataRequirement) b; 646 else 647 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a DataRequirement"); 648 } 649 650 public ParameterDefinition castToParameterDefinition(Base b) throws FHIRException { 651 if (b instanceof ParameterDefinition) 652 return (ParameterDefinition) b; 653 else 654 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ParameterDefinition"); 655 } 656 657 public TriggerDefinition castToTriggerDefinition(Base b) throws FHIRException { 658 if (b instanceof TriggerDefinition) 659 return (TriggerDefinition) b; 660 else 661 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a TriggerDefinition"); 662 } 663 664 public XhtmlNode castToXhtml(Base b) throws FHIRException { 665 if (b instanceof StringType) { 666 try { 667 return new XhtmlParser().parseFragment(((StringType) b).asStringValue()); 668 } catch (IOException e) { 669 throw new FHIRException(e); 670 } 671 } else 672 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to XHtml"); 673 } 674 675 public String castToXhtmlString(Base b) throws FHIRException { 676 if (b instanceof StringType) { 677 return ((StringType) b).asStringValue(); 678 } else 679 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to XHtml string"); 680 } 681 682 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 683 if (checkValid) 684 throw new FHIRException("Attempt to read invalid property '"+name+"' on type "+fhirType()); 685 return null; 686 } 687 688 public Base setProperty(int hash, String name, Base value) throws FHIRException { 689 throw new FHIRException("Attempt to write to invalid property '"+name+"' on type "+fhirType()); 690 } 691 692 public Base makeProperty(int hash, String name) throws FHIRException { 693 throw new FHIRException("Attempt to make an invalid property '"+name+"' on type "+fhirType()); 694 } 695 696 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 697 throw new FHIRException("Attempt to get types for an invalid property '"+name+"' on type "+fhirType()); 698 } 699 700 public static boolean equals(String v1, String v2) { 701 if (v1 == null && v2 == null) 702 return true; 703 else if (v1 == null || v2 == null) 704 return false; 705 else 706 return v1.equals(v2); 707 } 708 709 public boolean isResource() { 710 return false; 711 } 712 713 714 public abstract String getIdBase(); 715 public abstract void setIdBase(String value); 716 717 public Property getNamedProperty(String _name) throws FHIRException { 718 return getNamedProperty(_name.hashCode(), _name, false); 719 } 720 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 721 if (_checkValid) 722 throw new FHIRException("Attempt to read invalid property '"+_name+"' on type "+fhirType()); 723 return null; 724 } 725 726}