001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
036import java.util.List;
037
038import org.hl7.fhir.exceptions.FHIRException;
039import org.hl7.fhir.instance.model.api.IBaseDatatype;
040import org.hl7.fhir.instance.model.api.IBaseExtension;
041import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
042
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.DatatypeDef;
045import ca.uhn.fhir.model.api.annotation.Description;
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.dstu2016may.model.Type value;
065
066    private static final long serialVersionUID = 1240831878L;
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     * Constructor
085     */
086    public Extension(String theUrl) {
087      setUrl(theUrl);
088    }
089
090    /**
091     * Constructor
092     */
093    public Extension(String theUrl, IBaseDatatype theValue) {
094      setUrl(theUrl);
095      setValue(theValue);
096    }
097
098    /**
099     * @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
100     */
101    public UriType getUrlElement() { 
102      if (this.url == null)
103        if (Configuration.errorOnAutoCreate())
104          throw new Error("Attempt to auto-create Extension.url");
105        else if (Configuration.doAutoCreate())
106          this.url = new UriType(); // bb
107      return this.url;
108    }
109
110    public boolean hasUrlElement() { 
111      return this.url != null && !this.url.isEmpty();
112    }
113
114    public boolean hasUrl() { 
115      return this.url != null && !this.url.isEmpty();
116    }
117
118    /**
119     * @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
120     */
121    public Extension setUrlElement(UriType value) { 
122      this.url = value;
123      return this;
124    }
125
126    /**
127     * @return Source of the definition for the extension code - a logical name or a URL.
128     */
129    public String getUrl() { 
130      return this.url == null ? null : this.url.getValue();
131    }
132
133    /**
134     * @param value Source of the definition for the extension code - a logical name or a URL.
135     */
136    public Extension setUrl(String value) { 
137        if (this.url == null)
138          this.url = new UriType();
139        this.url.setValue(value);
140      return this;
141    }
142
143    /**
144     * @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).)
145     */
146    public org.hl7.fhir.dstu2016may.model.Type getValue() { 
147      return this.value;
148    }
149
150    public boolean hasValue() { 
151      return this.value != null && !this.value.isEmpty();
152    }
153
154    /**
155     * @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).)
156     */
157    public Extension setValue(org.hl7.fhir.dstu2016may.model.Type value) { 
158      this.value = value;
159      return this;
160    }
161
162      protected void listChildren(List<Property> childrenList) {
163        super.listChildren(childrenList);
164        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));
165        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));
166      }
167
168      @Override
169      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
170        switch (hash) {
171        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType
172        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // org.hl7.fhir.dstu2016may.model.Type
173        default: return super.getProperty(hash, name, checkValid);
174        }
175
176      }
177
178      @Override
179      public void setProperty(int hash, String name, Base value) throws FHIRException {
180        switch (hash) {
181        case 116079: // url
182          this.url = castToUri(value); // UriType
183          break;
184        case 111972721: // value
185          this.value = (org.hl7.fhir.dstu2016may.model.Type) value; // org.hl7.fhir.dstu2016may.model.Type
186          break;
187        default: super.setProperty(hash, name, value);
188        }
189
190      }
191
192      @Override
193      public void setProperty(String name, Base value) throws FHIRException {
194        if (name.equals("url"))
195          this.url = castToUri(value); // UriType
196        else if (name.equals("value[x]"))
197          this.value = (org.hl7.fhir.dstu2016may.model.Type) value; // org.hl7.fhir.dstu2016may.model.Type
198        else
199          super.setProperty(name, value);
200      }
201
202      @Override
203      public Base makeProperty(int hash, String name) throws FHIRException {
204        switch (hash) {
205        case 116079: throw new FHIRException("Cannot make property url as it is not a complex type"); // UriType
206        case -1410166417:  return getValue(); // org.hl7.fhir.dstu2016may.model.Type
207        default: return super.makeProperty(hash, name);
208        }
209
210      }
211
212      @Override
213      public Base addChild(String name) throws FHIRException {
214        if (name.equals("url")) {
215          throw new FHIRException("Cannot call addChild on a primitive type Extension.url");
216        }
217        else if (name.equals("valueBoolean")) {
218          this.value = new BooleanType();
219          return this.value;
220        }
221        else if (name.equals("valueInteger")) {
222          this.value = new IntegerType();
223          return this.value;
224        }
225        else if (name.equals("valueDecimal")) {
226          this.value = new DecimalType();
227          return this.value;
228        }
229        else if (name.equals("valueBase64Binary")) {
230          this.value = new Base64BinaryType();
231          return this.value;
232        }
233        else if (name.equals("valueInstant")) {
234          this.value = new InstantType();
235          return this.value;
236        }
237        else if (name.equals("valueString")) {
238          this.value = new StringType();
239          return this.value;
240        }
241        else if (name.equals("valueUri")) {
242          this.value = new UriType();
243          return this.value;
244        }
245        else if (name.equals("valueDate")) {
246          this.value = new DateType();
247          return this.value;
248        }
249        else if (name.equals("valueDateTime")) {
250          this.value = new DateTimeType();
251          return this.value;
252        }
253        else if (name.equals("valueTime")) {
254          this.value = new TimeType();
255          return this.value;
256        }
257        else if (name.equals("valueCode")) {
258          this.value = new CodeType();
259          return this.value;
260        }
261        else if (name.equals("valueOid")) {
262          this.value = new OidType();
263          return this.value;
264        }
265        else if (name.equals("valueId")) {
266          this.value = new IdType();
267          return this.value;
268        }
269        else if (name.equals("valueUnsignedInt")) {
270          this.value = new UnsignedIntType();
271          return this.value;
272        }
273        else if (name.equals("valuePositiveInt")) {
274          this.value = new PositiveIntType();
275          return this.value;
276        }
277        else if (name.equals("valueMarkdown")) {
278          this.value = new MarkdownType();
279          return this.value;
280        }
281        else if (name.equals("valueAnnotation")) {
282          this.value = new Annotation();
283          return this.value;
284        }
285        else if (name.equals("valueAttachment")) {
286          this.value = new Attachment();
287          return this.value;
288        }
289        else if (name.equals("valueIdentifier")) {
290          this.value = new Identifier();
291          return this.value;
292        }
293        else if (name.equals("valueCodeableConcept")) {
294          this.value = new CodeableConcept();
295          return this.value;
296        }
297        else if (name.equals("valueCoding")) {
298          this.value = new Coding();
299          return this.value;
300        }
301        else if (name.equals("valueQuantity")) {
302          this.value = new Quantity();
303          return this.value;
304        }
305        else if (name.equals("valueRange")) {
306          this.value = new Range();
307          return this.value;
308        }
309        else if (name.equals("valuePeriod")) {
310          this.value = new Period();
311          return this.value;
312        }
313        else if (name.equals("valueRatio")) {
314          this.value = new Ratio();
315          return this.value;
316        }
317        else if (name.equals("valueSampledData")) {
318          this.value = new SampledData();
319          return this.value;
320        }
321        else if (name.equals("valueSignature")) {
322          this.value = new Signature();
323          return this.value;
324        }
325        else if (name.equals("valueHumanName")) {
326          this.value = new HumanName();
327          return this.value;
328        }
329        else if (name.equals("valueAddress")) {
330          this.value = new Address();
331          return this.value;
332        }
333        else if (name.equals("valueContactPoint")) {
334          this.value = new ContactPoint();
335          return this.value;
336        }
337        else if (name.equals("valueTiming")) {
338          this.value = new Timing();
339          return this.value;
340        }
341        else if (name.equals("valueReference")) {
342          this.value = new Reference();
343          return this.value;
344        }
345        else if (name.equals("valueMeta")) {
346          this.value = new Meta();
347          return this.value;
348        }
349        else
350          return super.addChild(name);
351      }
352
353  public String fhirType() {
354    return "Extension";
355
356  }
357
358      public Extension copy() {
359        Extension dst = new Extension();
360        copyValues(dst);
361        dst.url = url == null ? null : url.copy();
362        dst.value = value == null ? null : value.copy();
363        return dst;
364      }
365
366      protected Extension typedCopy() {
367        return copy();
368      }
369
370      @Override
371      public boolean equalsDeep(Base other) {
372        if (!super.equalsDeep(other))
373          return false;
374        if (!(other instanceof Extension))
375          return false;
376        Extension o = (Extension) other;
377        return compareDeep(url, o.url, true) && compareDeep(value, o.value, true);
378      }
379
380      @Override
381      public boolean equalsShallow(Base other) {
382        if (!super.equalsShallow(other))
383          return false;
384        if (!(other instanceof Extension))
385          return false;
386        Extension o = (Extension) other;
387        return compareValues(url, o.url, true);
388      }
389
390      public boolean isEmpty() {
391        return super.isEmpty() && (url == null || url.isEmpty()) && (value == null || value.isEmpty())
392          ;
393      }
394
395
396}