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