001package org.hl7.fhir.dstu2.model; 002 003 004 005 006/* 007 Copyright (c) 2011+, HL7, Inc. 008 All rights reserved. 009 010 Redistribution and use in source and binary forms, with or without modification, 011 are permitted provided that the following conditions are met: 012 013 * Redistributions of source code must retain the above copyright notice, this 014 list of conditions and the following disclaimer. 015 * Redistributions in binary form must reproduce the above copyright notice, 016 this list of conditions and the following disclaimer in the documentation 017 and/or other materials provided with the distribution. 018 * Neither the name of HL7 nor the names of its contributors may be used to 019 endorse or promote products derived from this software without specific 020 prior written permission. 021 022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 025 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 026 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 027 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 028 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 029 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 030 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 031 POSSIBILITY OF SUCH DAMAGE. 032 033*/ 034 035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 036import java.util.List; 037 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.DatatypeDef; 040import ca.uhn.fhir.model.api.annotation.Description; 041import org.hl7.fhir.instance.model.api.IBaseExtension; 042import org.hl7.fhir.instance.model.api.IBaseHasExtensions; 043import org.hl7.fhir.exceptions.FHIRException; 044/** 045 * Optional Extensions 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.dstu2.model.Type value; 063 064 private static final long serialVersionUID = 1029480965L; 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 * @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 083 */ 084 public UriType getUrlElement() { 085 if (this.url == null) 086 if (Configuration.errorOnAutoCreate()) 087 throw new Error("Attempt to auto-create Extension.url"); 088 else if (Configuration.doAutoCreate()) 089 this.url = new UriType(); // bb 090 return this.url; 091 } 092 093 public boolean hasUrlElement() { 094 return this.url != null && !this.url.isEmpty(); 095 } 096 097 public boolean hasUrl() { 098 return this.url != null && !this.url.isEmpty(); 099 } 100 101 /** 102 * @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 103 */ 104 public Extension setUrlElement(UriType value) { 105 this.url = value; 106 return this; 107 } 108 109 /** 110 * @return Source of the definition for the extension code - a logical name or a URL. 111 */ 112 public String getUrl() { 113 return this.url == null ? null : this.url.getValue(); 114 } 115 116 /** 117 * @param value Source of the definition for the extension code - a logical name or a URL. 118 */ 119 public Extension setUrl(String value) { 120 if (this.url == null) 121 this.url = new UriType(); 122 this.url.setValue(value); 123 return this; 124 } 125 126 /** 127 * @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).) 128 */ 129 public org.hl7.fhir.dstu2.model.Type getValue() { 130 return this.value; 131 } 132 133 public boolean hasValue() { 134 return this.value != null && !this.value.isEmpty(); 135 } 136 137 /** 138 * @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).) 139 */ 140 public Extension setValue(org.hl7.fhir.dstu2.model.Type value) { 141 this.value = value; 142 return this; 143 } 144 145 protected void listChildren(List<Property> childrenList) { 146 super.listChildren(childrenList); 147 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)); 148 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)); 149 } 150 151 @Override 152 public void setProperty(String name, Base value) throws FHIRException { 153 if (name.equals("url")) 154 this.url = castToUri(value); // UriType 155 else if (name.equals("value[x]")) 156 this.value = (org.hl7.fhir.dstu2.model.Type) value; // org.hl7.fhir.dstu2.model.Type 157 else 158 super.setProperty(name, value); 159 } 160 161 @Override 162 public Base addChild(String name) throws FHIRException { 163 if (name.equals("url")) { 164 throw new FHIRException("Cannot call addChild on a primitive type Extension.url"); 165 } 166 else if (name.equals("valueBoolean")) { 167 this.value = new BooleanType(); 168 return this.value; 169 } 170 else if (name.equals("valueInteger")) { 171 this.value = new IntegerType(); 172 return this.value; 173 } 174 else if (name.equals("valueDecimal")) { 175 this.value = new DecimalType(); 176 return this.value; 177 } 178 else if (name.equals("valueBase64Binary")) { 179 this.value = new Base64BinaryType(); 180 return this.value; 181 } 182 else if (name.equals("valueInstant")) { 183 this.value = new InstantType(); 184 return this.value; 185 } 186 else if (name.equals("valueString")) { 187 this.value = new StringType(); 188 return this.value; 189 } 190 else if (name.equals("valueUri")) { 191 this.value = new UriType(); 192 return this.value; 193 } 194 else if (name.equals("valueDate")) { 195 this.value = new DateType(); 196 return this.value; 197 } 198 else if (name.equals("valueDateTime")) { 199 this.value = new DateTimeType(); 200 return this.value; 201 } 202 else if (name.equals("valueTime")) { 203 this.value = new TimeType(); 204 return this.value; 205 } 206 else if (name.equals("valueCode")) { 207 this.value = new CodeType(); 208 return this.value; 209 } 210 else if (name.equals("valueOid")) { 211 this.value = new OidType(); 212 return this.value; 213 } 214 else if (name.equals("valueId")) { 215 this.value = new IdType(); 216 return this.value; 217 } 218 else if (name.equals("valueUnsignedInt")) { 219 this.value = new UnsignedIntType(); 220 return this.value; 221 } 222 else if (name.equals("valuePositiveInt")) { 223 this.value = new PositiveIntType(); 224 return this.value; 225 } 226 else if (name.equals("valueMarkdown")) { 227 this.value = new MarkdownType(); 228 return this.value; 229 } 230 else if (name.equals("valueAnnotation")) { 231 this.value = new Annotation(); 232 return this.value; 233 } 234 else if (name.equals("valueAttachment")) { 235 this.value = new Attachment(); 236 return this.value; 237 } 238 else if (name.equals("valueIdentifier")) { 239 this.value = new Identifier(); 240 return this.value; 241 } 242 else if (name.equals("valueCodeableConcept")) { 243 this.value = new CodeableConcept(); 244 return this.value; 245 } 246 else if (name.equals("valueCoding")) { 247 this.value = new Coding(); 248 return this.value; 249 } 250 else if (name.equals("valueQuantity")) { 251 this.value = new Quantity(); 252 return this.value; 253 } 254 else if (name.equals("valueRange")) { 255 this.value = new Range(); 256 return this.value; 257 } 258 else if (name.equals("valuePeriod")) { 259 this.value = new Period(); 260 return this.value; 261 } 262 else if (name.equals("valueRatio")) { 263 this.value = new Ratio(); 264 return this.value; 265 } 266 else if (name.equals("valueSampledData")) { 267 this.value = new SampledData(); 268 return this.value; 269 } 270 else if (name.equals("valueSignature")) { 271 this.value = new Signature(); 272 return this.value; 273 } 274 else if (name.equals("valueHumanName")) { 275 this.value = new HumanName(); 276 return this.value; 277 } 278 else if (name.equals("valueAddress")) { 279 this.value = new Address(); 280 return this.value; 281 } 282 else if (name.equals("valueContactPoint")) { 283 this.value = new ContactPoint(); 284 return this.value; 285 } 286 else if (name.equals("valueTiming")) { 287 this.value = new Timing(); 288 return this.value; 289 } 290 else if (name.equals("valueReference")) { 291 this.value = new Reference(); 292 return this.value; 293 } 294 else if (name.equals("valueMeta")) { 295 this.value = new Meta(); 296 return this.value; 297 } 298 else 299 return super.addChild(name); 300 } 301 302 public String fhirType() { 303 return "Extension"; 304 305 } 306 307 public Extension copy() { 308 Extension dst = new Extension(); 309 copyValues(dst); 310 dst.url = url == null ? null : url.copy(); 311 dst.value = value == null ? null : value.copy(); 312 return dst; 313 } 314 315 protected Extension typedCopy() { 316 return copy(); 317 } 318 319 @Override 320 public boolean equalsDeep(Base other) { 321 if (!super.equalsDeep(other)) 322 return false; 323 if (!(other instanceof Extension)) 324 return false; 325 Extension o = (Extension) other; 326 return compareDeep(url, o.url, true) && compareDeep(value, o.value, true); 327 } 328 329 @Override 330 public boolean equalsShallow(Base other) { 331 if (!super.equalsShallow(other)) 332 return false; 333 if (!(other instanceof Extension)) 334 return false; 335 Extension o = (Extension) other; 336 return compareValues(url, o.url, true); 337 } 338 339 public boolean isEmpty() { 340 return super.isEmpty() && (url == null || url.isEmpty()) && (value == null || value.isEmpty()) 341 ; 342 } 343 344 345}