001package org.hl7.fhir.dstu3.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.dstu3 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023 024import java.io.IOException; 025import java.io.Serializable; 026import java.util.ArrayList; 027import java.util.HashMap; 028import java.util.List; 029import java.util.Map; 030 031import org.hl7.fhir.dstu3.elementmodel.Element; 032import org.hl7.fhir.dstu3.elementmodel.ObjectConverter; 033import org.hl7.fhir.exceptions.FHIRException; 034import org.hl7.fhir.instance.model.api.IBase; 035import org.hl7.fhir.utilities.Utilities; 036import org.hl7.fhir.utilities.xhtml.XhtmlNode; 037import org.hl7.fhir.utilities.xhtml.XhtmlParser; 038 039import ca.uhn.fhir.model.api.IElement; 040 041public abstract class Base implements Serializable, IBase, IElement { 042 043 /** 044 * User appended data items - allow users to add extra information to the class 045 */ 046private Map<String, Object> userData; 047 048 /** 049 * Round tracking xml comments for testing convenience 050 */ 051 private List<String> formatCommentsPre; 052 053 /** 054 * Round tracking xml comments for testing convenience 055 */ 056 private List<String> formatCommentsPost; 057 058 059 public Object getUserData(String name) { 060 if (userData == null) 061 return null; 062 return userData.get(name); 063 } 064 065 public void setUserData(String name, Object value) { 066 if (userData == null) 067 userData = new HashMap<String, Object>(); 068 userData.put(name, value); 069 } 070 071 public void clearUserData(String name) { 072 if (userData != null) 073 userData.remove(name); 074 } 075 076 public void setUserDataINN(String name, Object value) { 077 if (value == null) 078 return; 079 080 if (userData == null) 081 userData = new HashMap<String, Object>(); 082 userData.put(name, value); 083 } 084 085 public boolean hasUserData(String name) { 086 if (userData == null) 087 return false; 088 else 089 return userData.containsKey(name); 090 } 091 092 public String getUserString(String name) { 093 Object ud = getUserData(name); 094 if (ud == null) 095 return null; 096 if (ud instanceof String) 097 return (String) ud; 098 return ud.toString(); 099 } 100 101 public int getUserInt(String name) { 102 if (!hasUserData(name)) 103 return 0; 104 return (Integer) getUserData(name); 105 } 106 107 public boolean hasFormatComment() { 108 return (formatCommentsPre != null && !formatCommentsPre.isEmpty()) || (formatCommentsPost != null && !formatCommentsPost.isEmpty()); 109 } 110 111 public List<String> getFormatCommentsPre() { 112 if (formatCommentsPre == null) 113 formatCommentsPre = new ArrayList<String>(); 114 return formatCommentsPre; 115 } 116 117 public List<String> getFormatCommentsPost() { 118 if (formatCommentsPost == null) 119 formatCommentsPost = new ArrayList<String>(); 120 return formatCommentsPost; 121 } 122 123 // these 3 allow evaluation engines to get access to primitive values 124 public boolean isPrimitive() { 125 return false; 126 } 127 128 public boolean isBooleanPrimitive() { 129 return false; 130 } 131 132 public boolean hasPrimitiveValue() { 133 return isPrimitive(); 134 } 135 136 public String primitiveValue() { 137 return null; 138 } 139 140 public abstract String fhirType() ; 141 142 public boolean hasType(String... name) { 143 String t = fhirType(); 144 for (String n : name) 145 if (n.equalsIgnoreCase(t)) 146 return true; 147 return false; 148 } 149 150 protected abstract void listChildren(List<Property> result) ; 151 152 public Base setProperty(String name, Base value) throws FHIRException { 153 throw new FHIRException("Attempt to set unknown property "+name); 154 } 155 156 public Base addChild(String name) throws FHIRException { 157 throw new FHIRException("Attempt to add child with unknown name "+name); 158 } 159 160 /** 161 * Supports iterating the children elements in some generic processor or browser 162 * All defined children will be listed, even if they have no value on this instance 163 * 164 * Note that the actual content of primitive or xhtml elements is not iterated explicitly. 165 * To find these, the processing code must recognise the element as a primitive, typecast 166 * the value to a {@link Type}, and examine the value 167 * 168 * @return a list of all the children defined for this element 169 */ 170 public List<Property> children() { 171 List<Property> result = new ArrayList<Property>(); 172 listChildren(result); 173 return result; 174 } 175 176 public Property getChildByName(String name) { 177 List<Property> children = new ArrayList<Property>(); 178 listChildren(children); 179 for (Property c : children) 180 if (c.getName().equals(name)) 181 return c; 182 return null; 183 } 184 185 public List<Base> listChildrenByName(String name) throws FHIRException { 186 List<Base> result = new ArrayList<Base>(); 187 for (Base b : listChildrenByName(name, true)) 188 if (b != null) 189 result.add(b); 190 return result; 191 } 192 193 public Base[] listChildrenByName(String name, boolean checkValid) throws FHIRException { 194 if (name.equals("*")) { 195 List<Property> children = new ArrayList<Property>(); 196 listChildren(children); 197 List<Base> result = new ArrayList<Base>(); 198 for (Property c : children) 199 result.addAll(c.getValues()); 200 return result.toArray(new Base[result.size()]); 201 } 202 else 203 return getProperty(name.hashCode(), name, checkValid); 204 } 205 206 public boolean isEmpty() { 207 return true; // userData does not count 208 } 209 210 public boolean equalsDeep(Base other) { 211 return other != null; 212 } 213 214 public boolean equalsShallow(Base other) { 215 return other != null; 216 } 217 218 public static boolean compareDeep(List<? extends Base> e1, List<? extends Base> e2, boolean allowNull) { 219 if (noList(e1) && noList(e2) && allowNull) 220 return true; 221 if (noList(e1) || noList(e2)) 222 return false; 223 if (e1.size() != e2.size()) 224 return false; 225 for (int i = 0; i < e1.size(); i++) { 226 if (!compareDeep(e1.get(i), e2.get(i), allowNull)) 227 return false; 228 } 229 return true; 230 } 231 232 private static boolean noList(List<? extends Base> list) { 233 return list == null || list.isEmpty(); 234 } 235 236 public static boolean compareDeep(Base e1, Base e2, boolean allowNull) { 237 if (allowNull) { 238 boolean noLeft = e1 == null || e1.isEmpty(); 239 boolean noRight = e2 == null || e2.isEmpty(); 240 if (noLeft && noRight) { 241 return true; 242 } 243 } 244 if (e1 == null || e2 == null) 245 return false; 246 if (e2.isMetadataBased() && !e1.isMetadataBased()) // respect existing order for debugging consistency; outcome must be the same either way 247 return e2.equalsDeep(e1); 248 else 249 return e1.equalsDeep(e2); 250 } 251 252 public static boolean compareDeep(XhtmlNode div1, XhtmlNode div2, boolean allowNull) { 253 if (div1 == null && div2 == null && allowNull) 254 return true; 255 if (div1 == null || div2 == null) 256 return false; 257 return div1.equalsDeep(div2); 258 } 259 260 261 public static boolean compareValues(List<? extends PrimitiveType> e1, List<? extends PrimitiveType> e2, boolean allowNull) { 262 if (e1 == null && e2 == null && allowNull) 263 return true; 264 if (e1 == null || e2 == null) 265 return false; 266 if (e1.size() != e2.size()) 267 return false; 268 for (int i = 0; i < e1.size(); i++) { 269 if (!compareValues(e1.get(i), e2.get(i), allowNull)) 270 return false; 271 } 272 return true; 273 } 274 275 public static boolean compareValues(PrimitiveType e1, PrimitiveType e2, boolean allowNull) { 276 boolean noLeft = e1 == null || e1.isEmpty(); 277 boolean noRight = e2 == null || e2.isEmpty(); 278 if (noLeft && noRight && allowNull) { 279 return true; 280 } 281 if (noLeft != noRight) 282 return false; 283 return e1.equalsShallow(e2); 284 } 285 286 // -- converters for property setters 287 288 public Type castToType(Base b) throws FHIRException { 289 if (b instanceof Type) 290 return (Type) b; 291 else if (b.isMetadataBased()) 292 return ((org.hl7.fhir.dstu3.elementmodel.Element) b).asType(); 293 else 294 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Reference"); 295 } 296 297 298 public BooleanType castToBoolean(Base b) throws FHIRException { 299 if (b instanceof BooleanType) 300 return (BooleanType) b; 301 else 302 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Boolean"); 303 } 304 305 public IntegerType castToInteger(Base b) throws FHIRException { 306 if (b instanceof IntegerType) 307 return (IntegerType) b; 308 else 309 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Integer"); 310 } 311 312 public DecimalType castToDecimal(Base b) throws FHIRException { 313 if (b instanceof DecimalType) 314 return (DecimalType) b; 315 else 316 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Decimal"); 317 } 318 319 public Base64BinaryType castToBase64Binary(Base b) throws FHIRException { 320 if (b instanceof Base64BinaryType) 321 return (Base64BinaryType) b; 322 else 323 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Base64Binary"); 324 } 325 326 public InstantType castToInstant(Base b) throws FHIRException { 327 if (b instanceof InstantType) 328 return (InstantType) b; 329 else 330 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Instant"); 331 } 332 333 public StringType castToString(Base b) throws FHIRException { 334 if (b instanceof StringType) 335 return (StringType) b; 336 else if (b.hasPrimitiveValue()) 337 return new StringType(b.primitiveValue()); 338 else 339 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a String"); 340 } 341 342 public UriType castToUri(Base b) throws FHIRException { 343 if (b instanceof UriType) 344 return (UriType) b; 345 else if (b.hasPrimitiveValue()) 346 return new UriType(b.primitiveValue()); 347 else 348 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Uri"); 349 } 350 351 public DateType castToDate(Base b) throws FHIRException { 352 if (b instanceof DateType) 353 return (DateType) b; 354 else if (b.hasPrimitiveValue()) 355 return new DateType(b.primitiveValue()); 356 else 357 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Date"); 358 } 359 360 public DateTimeType castToDateTime(Base b) throws FHIRException { 361 if (b instanceof DateTimeType) 362 return (DateTimeType) b; 363 else if (b.fhirType().equals("dateTime")) 364 return new DateTimeType(b.primitiveValue()); 365 else 366 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a DateTime"); 367 } 368 369 public TimeType castToTime(Base b) throws FHIRException { 370 if (b instanceof TimeType) 371 return (TimeType) b; 372 else 373 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Time"); 374 } 375 376 public CodeType castToCode(Base b) throws FHIRException { 377 if (b instanceof CodeType) 378 return (CodeType) b; 379 else if (b.isPrimitive()) 380 return new CodeType(b.primitiveValue()); 381 else 382 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Code"); 383 } 384 385 public OidType castToOid(Base b) throws FHIRException { 386 if (b instanceof OidType) 387 return (OidType) b; 388 else 389 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Oid"); 390 } 391 392 public IdType castToId(Base b) throws FHIRException { 393 if (b instanceof IdType) 394 return (IdType) b; 395 else 396 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Id"); 397 } 398 399 public UnsignedIntType castToUnsignedInt(Base b) throws FHIRException { 400 if (b instanceof UnsignedIntType) 401 return (UnsignedIntType) b; 402 else 403 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a UnsignedInt"); 404 } 405 406 public PositiveIntType castToPositiveInt(Base b) throws FHIRException { 407 if (b instanceof PositiveIntType) 408 return (PositiveIntType) b; 409 else 410 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a PositiveInt"); 411 } 412 413 public MarkdownType castToMarkdown(Base b) throws FHIRException { 414 if (b instanceof MarkdownType) 415 return (MarkdownType) b; 416 else 417 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Markdown"); 418 } 419 420 public Annotation castToAnnotation(Base b) throws FHIRException { 421 if (b instanceof Annotation) 422 return (Annotation) b; 423 else 424 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Annotation"); 425 } 426 427 public Dosage castToDosage(Base b) throws FHIRException { 428 if (b instanceof Dosage) 429 return (Dosage) b; 430 else throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an DosageInstruction"); 431 } 432 433 434 public Attachment castToAttachment(Base b) throws FHIRException { 435 if (b instanceof Attachment) 436 return (Attachment) b; 437 else 438 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Attachment"); 439 } 440 441 public Identifier castToIdentifier(Base b) throws FHIRException { 442 if (b instanceof Identifier) 443 return (Identifier) b; 444 else 445 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Identifier"); 446 } 447 448 public CodeableConcept castToCodeableConcept(Base b) throws FHIRException { 449 if (b instanceof CodeableConcept) 450 return (CodeableConcept) b; 451 else if (b instanceof Element) { 452 return ObjectConverter.readAsCodeableConcept((Element) b); 453 } else if (b instanceof CodeType) { 454 CodeableConcept cc = new CodeableConcept(); 455 cc.addCoding().setCode(((CodeType) b).asStringValue()); 456 return cc; 457 } else 458 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a CodeableConcept"); 459 } 460 461 public Coding castToCoding(Base b) throws FHIRException { 462 if (b instanceof Coding) 463 return (Coding) b; 464 else if (b instanceof Element) { 465 return ObjectConverter.readAsCoding((Element) 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 if (b instanceof org.hl7.fhir.dstu3.elementmodel.Element && b.fhirType().equals("Reference")) { 604 org.hl7.fhir.dstu3.elementmodel.Element e = (org.hl7.fhir.dstu3.elementmodel.Element) b; 605 return new Reference().setReference(e.getChildValue("reference")).setDisplay(e.getChildValue("display")); 606 } else 607 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Reference"); 608 } 609 610 public Meta castToMeta(Base b) throws FHIRException { 611 if (b instanceof Meta) 612 return (Meta) b; 613 else 614 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Meta"); 615 } 616 617 public Extension castToExtension(Base b) throws FHIRException { 618 if (b instanceof Extension) 619 return (Extension) b; 620 else 621 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Extension"); 622 } 623 624 public Resource castToResource(Base b) throws FHIRException { 625 if (b instanceof Resource) 626 return (Resource) b; 627 else 628 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Resource"); 629 } 630 631 public Narrative castToNarrative(Base b) throws FHIRException { 632 if (b instanceof Narrative) 633 return (Narrative) b; 634 else 635 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Narrative"); 636 } 637 638 639 public ElementDefinition castToElementDefinition(Base b) throws FHIRException { 640 if (b instanceof ElementDefinition) 641 return (ElementDefinition) b; 642 else 643 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ElementDefinition"); 644 } 645 646 public DataRequirement castToDataRequirement(Base b) throws FHIRException { 647 if (b instanceof DataRequirement) 648 return (DataRequirement) b; 649 else 650 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a DataRequirement"); 651 } 652 653 public ParameterDefinition castToParameterDefinition(Base b) throws FHIRException { 654 if (b instanceof ParameterDefinition) 655 return (ParameterDefinition) b; 656 else 657 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ParameterDefinition"); 658 } 659 660 public TriggerDefinition castToTriggerDefinition(Base b) throws FHIRException { 661 if (b instanceof TriggerDefinition) 662 return (TriggerDefinition) b; 663 else 664 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a TriggerDefinition"); 665 } 666 667 public XhtmlNode castToXhtml(Base b) throws FHIRException { 668 if (b instanceof Element) { 669 return ((Element) b).getXhtml(); 670 } else if (b instanceof StringType) { 671 try { 672 return new XhtmlParser().parseFragment(((StringType) b).asStringValue()); 673 } catch (IOException e) { 674 throw new FHIRException(e); 675 } 676 } else 677 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to XHtml"); 678 } 679 680 public String castToXhtmlString(Base b) throws FHIRException { 681 if (b instanceof Element) { 682 return ((Element) b).getValue(); 683 } else if (b instanceof StringType) { 684 return ((StringType) b).asStringValue(); 685 } else 686 throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to XHtml string"); 687 } 688 689 protected boolean isMetadataBased() { 690 return false; 691 } 692 693 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 694 if (checkValid) 695 throw new FHIRException("Attempt to read invalid property '"+name+"' on type "+fhirType()); 696 return null; 697 } 698 699 public Base setProperty(int hash, String name, Base value) throws FHIRException { 700 throw new FHIRException("Attempt to write to invalid property '"+name+"' on type "+fhirType()); 701 } 702 703 public Base makeProperty(int hash, String name) throws FHIRException { 704 throw new FHIRException("Attempt to make an invalid property '"+name+"' on type "+fhirType()); 705 } 706 707 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 708 throw new FHIRException("Attempt to get types for an invalid property '"+name+"' on type "+fhirType()); 709 } 710 711 public static boolean equals(String v1, String v2) { 712 if (v1 == null && v2 == null) 713 return true; 714 else if (v1 == null || v2 == null) 715 return false; 716 else 717 return v1.equals(v2); 718 } 719 720 public boolean isResource() { 721 return false; 722 } 723 724 725 public abstract String getIdBase(); 726 public abstract void setIdBase(String value); 727 728 public Property getNamedProperty(String _name) throws FHIRException { 729 return getNamedProperty(_name.hashCode(), _name, false); 730 } 731 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 732 if (_checkValid) 733 throw new FHIRException("Attempt to read invalid property '"+_name+"' on type "+fhirType()); 734 return null; 735 } 736 737}