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