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/* 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 Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.x 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 - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for 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 - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list)." ) 081 protected org.hl7.fhir.dstu3.model.Type value; 082 083 private static final long serialVersionUID = 1240831878L; 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 - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).) 162 */ 163 public org.hl7.fhir.dstu3.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 - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list).) 173 */ 174 public Extension setValue(org.hl7.fhir.dstu3.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 - 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 } 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 - 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 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); 191 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); 192 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); 193 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); 194 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); 195 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); 196 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); 197 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); 198 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); 199 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); 200 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); 201 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); 202 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); 203 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); 204 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); 205 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); 206 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); 207 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); 208 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); 209 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); 210 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); 211 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); 212 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); 213 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); 214 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); 215 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); 216 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); 217 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); 218 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); 219 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); 220 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); 221 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); 222 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); 223 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); 224 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); 225 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); 226 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); 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.dstu3.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.dstu3.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.dstu3.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("valueBoolean")) { 294 this.value = new BooleanType(); 295 return this.value; 296 } 297 else if (name.equals("valueInteger")) { 298 this.value = new IntegerType(); 299 return this.value; 300 } 301 else if (name.equals("valueDecimal")) { 302 this.value = new DecimalType(); 303 return this.value; 304 } 305 else if (name.equals("valueBase64Binary")) { 306 this.value = new Base64BinaryType(); 307 return this.value; 308 } 309 else if (name.equals("valueInstant")) { 310 this.value = new InstantType(); 311 return this.value; 312 } 313 else if (name.equals("valueString")) { 314 this.value = new StringType(); 315 return this.value; 316 } 317 else if (name.equals("valueUri")) { 318 this.value = new UriType(); 319 return this.value; 320 } 321 else if (name.equals("valueDate")) { 322 this.value = new DateType(); 323 return this.value; 324 } 325 else if (name.equals("valueDateTime")) { 326 this.value = new DateTimeType(); 327 return this.value; 328 } 329 else if (name.equals("valueTime")) { 330 this.value = new TimeType(); 331 return this.value; 332 } 333 else if (name.equals("valueCode")) { 334 this.value = new CodeType(); 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("valueId")) { 342 this.value = new IdType(); 343 return this.value; 344 } 345 else if (name.equals("valueUnsignedInt")) { 346 this.value = new UnsignedIntType(); 347 return this.value; 348 } 349 else if (name.equals("valuePositiveInt")) { 350 this.value = new PositiveIntType(); 351 return this.value; 352 } 353 else if (name.equals("valueMarkdown")) { 354 this.value = new MarkdownType(); 355 return this.value; 356 } 357 else if (name.equals("valueAnnotation")) { 358 this.value = new Annotation(); 359 return this.value; 360 } 361 else if (name.equals("valueAttachment")) { 362 this.value = new Attachment(); 363 return this.value; 364 } 365 else if (name.equals("valueIdentifier")) { 366 this.value = new Identifier(); 367 return this.value; 368 } 369 else if (name.equals("valueCodeableConcept")) { 370 this.value = new CodeableConcept(); 371 return this.value; 372 } 373 else if (name.equals("valueCoding")) { 374 this.value = new Coding(); 375 return this.value; 376 } 377 else if (name.equals("valueQuantity")) { 378 this.value = new Quantity(); 379 return this.value; 380 } 381 else if (name.equals("valueRange")) { 382 this.value = new Range(); 383 return this.value; 384 } 385 else if (name.equals("valuePeriod")) { 386 this.value = new Period(); 387 return this.value; 388 } 389 else if (name.equals("valueRatio")) { 390 this.value = new Ratio(); 391 return this.value; 392 } 393 else if (name.equals("valueSampledData")) { 394 this.value = new SampledData(); 395 return this.value; 396 } 397 else if (name.equals("valueSignature")) { 398 this.value = new Signature(); 399 return this.value; 400 } 401 else if (name.equals("valueHumanName")) { 402 this.value = new HumanName(); 403 return this.value; 404 } 405 else if (name.equals("valueAddress")) { 406 this.value = new Address(); 407 return this.value; 408 } 409 else if (name.equals("valueContactPoint")) { 410 this.value = new ContactPoint(); 411 return this.value; 412 } 413 else if (name.equals("valueTiming")) { 414 this.value = new Timing(); 415 return this.value; 416 } 417 else if (name.equals("valueReference")) { 418 this.value = new Reference(); 419 return this.value; 420 } 421 else if (name.equals("valueMeta")) { 422 this.value = new Meta(); 423 return this.value; 424 } 425 else 426 return super.addChild(name); 427 } 428 429 public String fhirType() { 430 return "Extension"; 431 432 } 433 434 public Extension copy() { 435 Extension dst = new Extension(); 436 copyValues(dst); 437 dst.url = url == null ? null : url.copy(); 438 dst.value = value == null ? null : value.copy(); 439 return dst; 440 } 441 442 protected Extension typedCopy() { 443 return copy(); 444 } 445 446 @Override 447 public boolean equalsDeep(Base other_) { 448 if (!super.equalsDeep(other_)) 449 return false; 450 if (!(other_ instanceof Extension)) 451 return false; 452 Extension o = (Extension) other_; 453 return compareDeep(url, o.url, true) && compareDeep(value, o.value, true); 454 } 455 456 @Override 457 public boolean equalsShallow(Base other_) { 458 if (!super.equalsShallow(other_)) 459 return false; 460 if (!(other_ instanceof Extension)) 461 return false; 462 Extension o = (Extension) other_; 463 return compareValues(url, o.url, true); 464 } 465 466 public boolean isEmpty() { 467 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(url, value); 468 } 469 470 471} 472