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