001package org.hl7.fhir.instance.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 Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 033import java.util.List; 034 035import org.hl7.fhir.exceptions.FHIRException; 036import org.hl7.fhir.instance.model.api.IBaseExtension; 037import org.hl7.fhir.instance.model.api.IBaseHasExtensions; 038 039import ca.uhn.fhir.model.api.annotation.*; 040/** 041 * Optional Extensions Element - found in all resources. 042 */ 043@DatatypeDef(name="Extension") 044public class Extension extends BaseExtension implements IBaseExtension<Extension, Type>, IBaseHasExtensions { 045 046 /** 047 * Source of the definition for the extension code - a logical name or a URL. 048 */ 049 @Child(name = "url", type = {UriType.class}, order=0, min=1, max=1, modifier=false, summary=false) 050 @Description(shortDefinition="identifies the meaning of the extension", formalDefinition="Source of the definition for the extension code - a logical name or a URL." ) 051 protected UriType url; 052 053 /** 054 * Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list). 055 */ 056 @Child(name = "value", type = {}, order=1, min=0, max=1, modifier=false, summary=false) 057 @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)." ) 058 protected org.hl7.fhir.instance.model.Type value; 059 060 private static final long serialVersionUID = 1029480965L; 061 062 /* 063 * Constructor 064 */ 065 public Extension() { 066 super(); 067 } 068 069 /* 070 * Constructor 071 */ 072 public Extension(UriType url) { 073 super(); 074 this.url = url; 075 } 076 077 /** 078 * @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 079 */ 080 public UriType getUrlElement() { 081 if (this.url == null) 082 if (Configuration.errorOnAutoCreate()) 083 throw new Error("Attempt to auto-create Extension.url"); 084 else if (Configuration.doAutoCreate()) 085 this.url = new UriType(); // bb 086 return this.url; 087 } 088 089 public boolean hasUrlElement() { 090 return this.url != null && !this.url.isEmpty(); 091 } 092 093 public boolean hasUrl() { 094 return this.url != null && !this.url.isEmpty(); 095 } 096 097 /** 098 * @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 099 */ 100 public Extension setUrlElement(UriType value) { 101 this.url = value; 102 return this; 103 } 104 105 /** 106 * @return Source of the definition for the extension code - a logical name or a URL. 107 */ 108 public String getUrl() { 109 return this.url == null ? null : this.url.getValue(); 110 } 111 112 /** 113 * @param value Source of the definition for the extension code - a logical name or a URL. 114 */ 115 public Extension setUrl(String value) { 116 if (this.url == null) 117 this.url = new UriType(); 118 this.url.setValue(value); 119 return this; 120 } 121 122 /** 123 * @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).) 124 */ 125 public org.hl7.fhir.instance.model.Type getValue() { 126 return this.value; 127 } 128 129 public boolean hasValue() { 130 return this.value != null && !this.value.isEmpty(); 131 } 132 133 /** 134 * @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).) 135 */ 136 public Extension setValue(org.hl7.fhir.instance.model.Type value) { 137 this.value = value; 138 return this; 139 } 140 141 protected void listChildren(List<Property> childrenList) { 142 super.listChildren(childrenList); 143 childrenList.add(new Property("url", "uri", "Source of the definition for the extension code - a logical name or a URL.", 0, java.lang.Integer.MAX_VALUE, url)); 144 childrenList.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, java.lang.Integer.MAX_VALUE, value)); 145 } 146 147 @Override 148 public void setProperty(String name, Base value) throws FHIRException { 149 if (name.equals("url")) 150 this.url = castToUri(value); // UriType 151 else if (name.equals("value[x]")) 152 this.value = (org.hl7.fhir.instance.model.Type) value; // org.hl7.fhir.instance.model.Type 153 else 154 super.setProperty(name, value); 155 } 156 157 @Override 158 public Base addChild(String name) throws FHIRException { 159 if (name.equals("url")) { 160 throw new FHIRException("Cannot call addChild on a primitive type Extension.url"); 161 } 162 else if (name.equals("valueBoolean")) { 163 this.value = new BooleanType(); 164 return this.value; 165 } 166 else if (name.equals("valueInteger")) { 167 this.value = new IntegerType(); 168 return this.value; 169 } 170 else if (name.equals("valueDecimal")) { 171 this.value = new DecimalType(); 172 return this.value; 173 } 174 else if (name.equals("valueBase64Binary")) { 175 this.value = new Base64BinaryType(); 176 return this.value; 177 } 178 else if (name.equals("valueInstant")) { 179 this.value = new InstantType(); 180 return this.value; 181 } 182 else if (name.equals("valueString")) { 183 this.value = new StringType(); 184 return this.value; 185 } 186 else if (name.equals("valueUri")) { 187 this.value = new UriType(); 188 return this.value; 189 } 190 else if (name.equals("valueDate")) { 191 this.value = new DateType(); 192 return this.value; 193 } 194 else if (name.equals("valueDateTime")) { 195 this.value = new DateTimeType(); 196 return this.value; 197 } 198 else if (name.equals("valueTime")) { 199 this.value = new TimeType(); 200 return this.value; 201 } 202 else if (name.equals("valueCode")) { 203 this.value = new CodeType(); 204 return this.value; 205 } 206 else if (name.equals("valueOid")) { 207 this.value = new OidType(); 208 return this.value; 209 } 210 else if (name.equals("valueId")) { 211 this.value = new IdType(); 212 return this.value; 213 } 214 else if (name.equals("valueUnsignedInt")) { 215 this.value = new UnsignedIntType(); 216 return this.value; 217 } 218 else if (name.equals("valuePositiveInt")) { 219 this.value = new PositiveIntType(); 220 return this.value; 221 } 222 else if (name.equals("valueMarkdown")) { 223 this.value = new MarkdownType(); 224 return this.value; 225 } 226 else if (name.equals("valueAnnotation")) { 227 this.value = new Annotation(); 228 return this.value; 229 } 230 else if (name.equals("valueAttachment")) { 231 this.value = new Attachment(); 232 return this.value; 233 } 234 else if (name.equals("valueIdentifier")) { 235 this.value = new Identifier(); 236 return this.value; 237 } 238 else if (name.equals("valueCodeableConcept")) { 239 this.value = new CodeableConcept(); 240 return this.value; 241 } 242 else if (name.equals("valueCoding")) { 243 this.value = new Coding(); 244 return this.value; 245 } 246 else if (name.equals("valueQuantity")) { 247 this.value = new Quantity(); 248 return this.value; 249 } 250 else if (name.equals("valueRange")) { 251 this.value = new Range(); 252 return this.value; 253 } 254 else if (name.equals("valuePeriod")) { 255 this.value = new Period(); 256 return this.value; 257 } 258 else if (name.equals("valueRatio")) { 259 this.value = new Ratio(); 260 return this.value; 261 } 262 else if (name.equals("valueSampledData")) { 263 this.value = new SampledData(); 264 return this.value; 265 } 266 else if (name.equals("valueSignature")) { 267 this.value = new Signature(); 268 return this.value; 269 } 270 else if (name.equals("valueHumanName")) { 271 this.value = new HumanName(); 272 return this.value; 273 } 274 else if (name.equals("valueAddress")) { 275 this.value = new Address(); 276 return this.value; 277 } 278 else if (name.equals("valueContactPoint")) { 279 this.value = new ContactPoint(); 280 return this.value; 281 } 282 else if (name.equals("valueTiming")) { 283 this.value = new Timing(); 284 return this.value; 285 } 286 else if (name.equals("valueReference")) { 287 this.value = new Reference(); 288 return this.value; 289 } 290 else if (name.equals("valueMeta")) { 291 this.value = new Meta(); 292 return this.value; 293 } 294 else 295 return super.addChild(name); 296 } 297 298 public String fhirType() { 299 return "Extension"; 300 301 } 302 303 public Extension copy() { 304 Extension dst = new Extension(); 305 copyValues(dst); 306 dst.url = url == null ? null : url.copy(); 307 dst.value = value == null ? null : value.copy(); 308 return dst; 309 } 310 311 protected Extension typedCopy() { 312 return copy(); 313 } 314 315 @Override 316 public boolean equalsDeep(Base other) { 317 if (!super.equalsDeep(other)) 318 return false; 319 if (!(other instanceof Extension)) 320 return false; 321 Extension o = (Extension) other; 322 return compareDeep(url, o.url, true) && compareDeep(value, o.value, true); 323 } 324 325 @Override 326 public boolean equalsShallow(Base other) { 327 if (!super.equalsShallow(other)) 328 return false; 329 if (!(other instanceof Extension)) 330 return false; 331 Extension o = (Extension) other; 332 return compareValues(url, o.url, true); 333 } 334 335 public boolean isEmpty() { 336 return super.isEmpty() && (url == null || url.isEmpty()) && (value == null || value.isEmpty()) 337 ; 338 } 339 340 341} 342