001package org.hl7.fhir.r4.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 Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0 033 034import java.util.*; 035 036import org.hl7.fhir.utilities.Utilities; 037import ca.uhn.fhir.model.api.annotation.Child; 038import ca.uhn.fhir.model.api.annotation.ChildOrder; 039import ca.uhn.fhir.model.api.annotation.Description; 040import ca.uhn.fhir.model.api.annotation.DatatypeDef; 041import ca.uhn.fhir.model.api.annotation.Block; 042import org.hl7.fhir.instance.model.api.*; 043import org.hl7.fhir.exceptions.FHIRException; 044/** 045 * Optional Extension Element - found in all resources. 046 */ 047@DatatypeDef(name="Extension") 048public class Extension extends BaseExtension implements IBaseExtension<Extension, Type>, IBaseHasExtensions { 049 050 /** 051 * Source of the definition for the extension code - a logical name or a URL. 052 */ 053 @Child(name = "url", type = {UriType.class}, order=0, min=1, max=1, modifier=false, summary=false) 054 @Description(shortDefinition="identifies the meaning of the extension", formalDefinition="Source of the definition for the extension code - a logical name or a URL." ) 055 protected UriType url; 056 057 /** 058 * Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list). 059 */ 060 @Child(name = "value", type = {}, order=1, min=0, max=1, modifier=false, summary=false) 061 @Description(shortDefinition="Value of extension", formalDefinition="Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list)." ) 062 protected org.hl7.fhir.r4.model.Type value; 063 064 private static final long serialVersionUID = 194602931L; 065 066 /** 067 * Constructor 068 */ 069 public Extension() { 070 super(); 071 } 072 073 /** 074 * Constructor 075 */ 076 public Extension(UriType url) { 077 super(); 078 this.url = url; 079 } 080 081 /** 082 * Constructor 083 */ 084 public Extension(String theUrl) { 085 setUrl(theUrl); 086 } 087 088 /** 089 * Constructor 090 */ 091 public Extension(String theUrl, IBaseDatatype theValue) { 092 setUrl(theUrl); 093 setValue(theValue); 094 } 095 096 /** 097 * @return {@link #url} (Source of the definition for the extension code - a logical name or a URL.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value 098 */ 099 public UriType getUrlElement() { 100 if (this.url == null) 101 if (Configuration.errorOnAutoCreate()) 102 throw new Error("Attempt to auto-create Extension.url"); 103 else if (Configuration.doAutoCreate()) 104 this.url = new UriType(); // bb 105 return this.url; 106 } 107 108 public boolean hasUrlElement() { 109 return this.url != null && !this.url.isEmpty(); 110 } 111 112 public boolean hasUrl() { 113 return this.url != null && !this.url.isEmpty(); 114 } 115 116 /** 117 * @param value {@link #url} (Source of the definition for the extension code - a logical name or a URL.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value 118 */ 119 public Extension setUrlElement(UriType value) { 120 this.url = value; 121 return this; 122 } 123 124 /** 125 * @return Source of the definition for the extension code - a logical name or a URL. 126 */ 127 public String getUrl() { 128 return this.url == null ? null : this.url.getValue(); 129 } 130 131 /** 132 * @param value Source of the definition for the extension code - a logical name or a URL. 133 */ 134 public Extension setUrl(String value) { 135 if (this.url == null) 136 this.url = new UriType(); 137 this.url.setValue(value); 138 return this; 139 } 140 141 /** 142 * @return {@link #value} (Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).) 143 */ 144 public org.hl7.fhir.r4.model.Type getValue() { 145 return this.value; 146 } 147 148 public boolean hasValue() { 149 return this.value != null && !this.value.isEmpty(); 150 } 151 152 /** 153 * @param value {@link #value} (Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).) 154 */ 155 public Extension setValue(org.hl7.fhir.r4.model.Type value) { 156 this.value = value; 157 return this; 158 } 159 160 protected void listChildren(List<Property> children) { 161 super.listChildren(children); 162 children.add(new Property("url", "uri", "Source of the definition for the extension code - a logical name or a URL.", 0, 1, url)); 163 children.add(new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value)); 164 } 165 166 @Override 167 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 168 switch (_hash) { 169 case 116079: /*url*/ return new Property("url", "uri", "Source of the definition for the extension code - a logical name or a URL.", 0, 1, url); 170 case -1410166417: /*value[x]*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 171 case 111972721: /*value*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 172 case -1535024575: /*valueBase64Binary*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 173 case 733421943: /*valueBoolean*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 174 case -786218365: /*valueCanonical*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 175 case -766209282: /*valueCode*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 176 case -766192449: /*valueDate*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 177 case 1047929900: /*valueDateTime*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 178 case -2083993440: /*valueDecimal*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 179 case 231604844: /*valueId*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 180 case -1668687056: /*valueInstant*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 181 case -1668204915: /*valueInteger*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 182 case -497880704: /*valueMarkdown*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 183 case -1410178407: /*valueOid*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 184 case -1249932027: /*valuePositiveInt*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 185 case -1424603934: /*valueString*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 186 case -765708322: /*valueTime*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 187 case 26529417: /*valueUnsignedInt*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 188 case -1410172357: /*valueUri*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 189 case -1410172354: /*valueUrl*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 190 case -765667124: /*valueUuid*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 191 case -478981821: /*valueAddress*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 192 case -67108992: /*valueAnnotation*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 193 case -475566732: /*valueAttachment*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 194 case 924902896: /*valueCodeableConcept*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 195 case -1887705029: /*valueCoding*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 196 case 944904545: /*valueContactPoint*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 197 case -2026205465: /*valueHumanName*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 198 case -130498310: /*valueIdentifier*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 199 case -1524344174: /*valuePeriod*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 200 case -2029823716: /*valueQuantity*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 201 case 2030761548: /*valueRange*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 202 case 2030767386: /*valueRatio*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 203 case 1755241690: /*valueReference*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 204 case -962229101: /*valueSampledData*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 205 case -540985785: /*valueSignature*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 206 case -1406282469: /*valueTiming*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 207 case -1858636920: /*valueDosage*/ return new Property("value[x]", "*", "Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).", 0, 1, value); 208 default: return super.getNamedProperty(_hash, _name, _checkValid); 209 } 210 211 } 212 213 @Override 214 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 215 switch (hash) { 216 case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType 217 case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // org.hl7.fhir.r4.model.Type 218 default: return super.getProperty(hash, name, checkValid); 219 } 220 221 } 222 223 @Override 224 public Base setProperty(int hash, String name, Base value) throws FHIRException { 225 switch (hash) { 226 case 116079: // url 227 this.url = castToUri(value); // UriType 228 return value; 229 case 111972721: // value 230 this.value = castToType(value); // org.hl7.fhir.r4.model.Type 231 return value; 232 default: return super.setProperty(hash, name, value); 233 } 234 235 } 236 237 @Override 238 public Base setProperty(String name, Base value) throws FHIRException { 239 if (name.equals("url")) { 240 this.url = castToUri(value); // UriType 241 } else if (name.equals("value[x]")) { 242 this.value = castToType(value); // org.hl7.fhir.r4.model.Type 243 } else 244 return super.setProperty(name, value); 245 return value; 246 } 247 248 @Override 249 public Base makeProperty(int hash, String name) throws FHIRException { 250 switch (hash) { 251 case 116079: return getUrlElement(); 252 case -1410166417: return getValue(); 253 case 111972721: return getValue(); 254 default: return super.makeProperty(hash, name); 255 } 256 257 } 258 259 @Override 260 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 261 switch (hash) { 262 case 116079: /*url*/ return new String[] {"uri"}; 263 case 111972721: /*value*/ return new String[] {"*"}; 264 default: return super.getTypesForProperty(hash, name); 265 } 266 267 } 268 269 @Override 270 public Base addChild(String name) throws FHIRException { 271 if (name.equals("url")) { 272 throw new FHIRException("Cannot call addChild on a primitive type Extension.url"); 273 } 274 else if (name.equals("valueBase64Binary")) { 275 this.value = new Base64BinaryType(); 276 return this.value; 277 } 278 else if (name.equals("valueBoolean")) { 279 this.value = new BooleanType(); 280 return this.value; 281 } 282 else if (name.equals("valueCanonical")) { 283 this.value = new CanonicalType(); 284 return this.value; 285 } 286 else if (name.equals("valueCode")) { 287 this.value = new CodeType(); 288 return this.value; 289 } 290 else if (name.equals("valueDate")) { 291 this.value = new DateType(); 292 return this.value; 293 } 294 else if (name.equals("valueDateTime")) { 295 this.value = new DateTimeType(); 296 return this.value; 297 } 298 else if (name.equals("valueDecimal")) { 299 this.value = new DecimalType(); 300 return this.value; 301 } 302 else if (name.equals("valueId")) { 303 this.value = new IdType(); 304 return this.value; 305 } 306 else if (name.equals("valueInstant")) { 307 this.value = new InstantType(); 308 return this.value; 309 } 310 else if (name.equals("valueInteger")) { 311 this.value = new IntegerType(); 312 return this.value; 313 } 314 else if (name.equals("valueMarkdown")) { 315 this.value = new MarkdownType(); 316 return this.value; 317 } 318 else if (name.equals("valueOid")) { 319 this.value = new OidType(); 320 return this.value; 321 } 322 else if (name.equals("valuePositiveInt")) { 323 this.value = new PositiveIntType(); 324 return this.value; 325 } 326 else if (name.equals("valueString")) { 327 this.value = new StringType(); 328 return this.value; 329 } 330 else if (name.equals("valueTime")) { 331 this.value = new TimeType(); 332 return this.value; 333 } 334 else if (name.equals("valueUnsignedInt")) { 335 this.value = new UnsignedIntType(); 336 return this.value; 337 } 338 else if (name.equals("valueUri")) { 339 this.value = new UriType(); 340 return this.value; 341 } 342 else if (name.equals("valueUrl")) { 343 this.value = new UrlType(); 344 return this.value; 345 } 346 else if (name.equals("valueUuid")) { 347 this.value = new UuidType(); 348 return this.value; 349 } 350 else if (name.equals("valueAddress")) { 351 this.value = new Address(); 352 return this.value; 353 } 354 else if (name.equals("valueAge")) { 355 this.value = new Age(); 356 return this.value; 357 } 358 else if (name.equals("valueAnnotation")) { 359 this.value = new Annotation(); 360 return this.value; 361 } 362 else if (name.equals("valueAttachment")) { 363 this.value = new Attachment(); 364 return this.value; 365 } 366 else if (name.equals("valueCodeableConcept")) { 367 this.value = new CodeableConcept(); 368 return this.value; 369 } 370 else if (name.equals("valueCoding")) { 371 this.value = new Coding(); 372 return this.value; 373 } 374 else if (name.equals("valueContactPoint")) { 375 this.value = new ContactPoint(); 376 return this.value; 377 } 378 else if (name.equals("valueCount")) { 379 this.value = new Count(); 380 return this.value; 381 } 382 else if (name.equals("valueDistance")) { 383 this.value = new Distance(); 384 return this.value; 385 } 386 else if (name.equals("valueDuration")) { 387 this.value = new Duration(); 388 return this.value; 389 } 390 else if (name.equals("valueHumanName")) { 391 this.value = new HumanName(); 392 return this.value; 393 } 394 else if (name.equals("valueIdentifier")) { 395 this.value = new Identifier(); 396 return this.value; 397 } 398 else if (name.equals("valueMoney")) { 399 this.value = new Money(); 400 return this.value; 401 } 402 else if (name.equals("valuePeriod")) { 403 this.value = new Period(); 404 return this.value; 405 } 406 else if (name.equals("valueQuantity")) { 407 this.value = new Quantity(); 408 return this.value; 409 } 410 else if (name.equals("valueRange")) { 411 this.value = new Range(); 412 return this.value; 413 } 414 else if (name.equals("valueRatio")) { 415 this.value = new Ratio(); 416 return this.value; 417 } 418 else if (name.equals("valueReference")) { 419 this.value = new Reference(); 420 return this.value; 421 } 422 else if (name.equals("valueSampledData")) { 423 this.value = new SampledData(); 424 return this.value; 425 } 426 else if (name.equals("valueSignature")) { 427 this.value = new Signature(); 428 return this.value; 429 } 430 else if (name.equals("valueTiming")) { 431 this.value = new Timing(); 432 return this.value; 433 } 434 else if (name.equals("valueParameterDefinition")) { 435 this.value = new ParameterDefinition(); 436 return this.value; 437 } 438 else if (name.equals("valueDataRequirement")) { 439 this.value = new DataRequirement(); 440 return this.value; 441 } 442 else if (name.equals("valueRelatedArtifact")) { 443 this.value = new RelatedArtifact(); 444 return this.value; 445 } 446 else if (name.equals("valueContactDetail")) { 447 this.value = new ContactDetail(); 448 return this.value; 449 } 450 else if (name.equals("valueContributor")) { 451 this.value = new Contributor(); 452 return this.value; 453 } 454 else if (name.equals("valueTriggerDefinition")) { 455 this.value = new TriggerDefinition(); 456 return this.value; 457 } 458 else if (name.equals("valueExpression")) { 459 this.value = new Expression(); 460 return this.value; 461 } 462 else if (name.equals("valueUsageContext")) { 463 this.value = new UsageContext(); 464 return this.value; 465 } 466 else if (name.equals("valueDosage")) { 467 this.value = new Dosage(); 468 return this.value; 469 } 470 else 471 return super.addChild(name); 472 } 473 474 public String fhirType() { 475 return "Extension"; 476 477 } 478 479 public Extension copy() { 480 Extension dst = new Extension(); 481 copyValues(dst); 482 dst.url = url == null ? null : url.copy(); 483 dst.value = value == null ? null : value.copy(); 484 return dst; 485 } 486 487 protected Extension typedCopy() { 488 return copy(); 489 } 490 491 @Override 492 public boolean equalsDeep(Base other_) { 493 if (!super.equalsDeep(other_)) 494 return false; 495 if (!(other_ instanceof Extension)) 496 return false; 497 Extension o = (Extension) other_; 498 return compareDeep(url, o.url, true) && compareDeep(value, o.value, true); 499 } 500 501 @Override 502 public boolean equalsShallow(Base other_) { 503 if (!super.equalsShallow(other_)) 504 return false; 505 if (!(other_ instanceof Extension)) 506 return false; 507 Extension o = (Extension) other_; 508 return compareValues(url, o.url, true); 509 } 510 511 public boolean isEmpty() { 512 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(url, value); 513 } 514 515 516} 517