001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.List;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.IAnyResource;
037import org.hl7.fhir.utilities.Utilities;
038
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.Description;
041/**
042 * This is the base resource type for everything.
043 */
044public abstract class Resource extends BaseResource implements IAnyResource {
045
046    /**
047     * The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
048     */
049    @Child(name = "id", type = {IdType.class}, order=0, min=0, max=1, modifier=false, summary=true)
050    @Description(shortDefinition="Logical id of this artifact", formalDefinition="The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes." )
051    protected IdType id;
052
053    /**
054     * The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.
055     */
056    @Child(name = "meta", type = {Meta.class}, order=1, min=0, max=1, modifier=false, summary=true)
057    @Description(shortDefinition="Metadata about the resource", formalDefinition="The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource." )
058    protected Meta meta;
059
060    /**
061     * A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.
062     */
063    @Child(name = "implicitRules", type = {UriType.class}, order=2, min=0, max=1, modifier=true, summary=true)
064    @Description(shortDefinition="A set of rules under which this content was created", formalDefinition="A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content." )
065    protected UriType implicitRules;
066
067    /**
068     * The base language in which the resource is written.
069     */
070    @Child(name = "language", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=false)
071    @Description(shortDefinition="Language of the resource content", formalDefinition="The base language in which the resource is written." )
072    protected CodeType language;
073
074    private static final long serialVersionUID = -559462759L;
075
076  /**
077   * Constructor
078   */
079    public Resource() {
080      super();
081    }
082
083    /**
084     * @return {@link #id} (The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value
085     */
086    public IdType getIdElement() { 
087      if (this.id == null)
088        if (Configuration.errorOnAutoCreate())
089          throw new Error("Attempt to auto-create Resource.id");
090        else if (Configuration.doAutoCreate())
091          this.id = new IdType(); // bb
092      return this.id;
093    }
094
095    public boolean hasIdElement() { 
096      return this.id != null && !this.id.isEmpty();
097    }
098
099    public boolean hasId() { 
100      return this.id != null && !this.id.isEmpty();
101    }
102
103    /**
104     * @param value {@link #id} (The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value
105     */
106    @Override
107         public Resource setIdElement(IdType value) {
108      this.id = value;
109      return this;
110    }
111
112    /**
113     * @return The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
114     */
115    public String getId() { 
116      return this.id == null ? null : this.id.getValue();
117    }
118
119    /**
120     * @param value The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
121     */
122    public Resource setId(String value) { 
123      if (Utilities.noString(value))
124        this.id = null;
125      else {
126        if (this.id == null)
127          this.id = new IdType();
128        this.id.setValue(value);
129      }
130      return this;
131    }
132
133    /**
134     * @return {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.)
135     */
136    public Meta getMeta() { 
137      if (this.meta == null)
138        if (Configuration.errorOnAutoCreate())
139          throw new Error("Attempt to auto-create Resource.meta");
140        else if (Configuration.doAutoCreate())
141          this.meta = new Meta(); // cc
142      return this.meta;
143    }
144
145    public boolean hasMeta() { 
146      return this.meta != null && !this.meta.isEmpty();
147    }
148
149    /**
150     * @param value {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.)
151     */
152    public Resource setMeta(Meta value) { 
153      this.meta = value;
154      return this;
155    }
156
157    /**
158     * @return {@link #implicitRules} (A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value
159     */
160    public UriType getImplicitRulesElement() { 
161      if (this.implicitRules == null)
162        if (Configuration.errorOnAutoCreate())
163          throw new Error("Attempt to auto-create Resource.implicitRules");
164        else if (Configuration.doAutoCreate())
165          this.implicitRules = new UriType(); // bb
166      return this.implicitRules;
167    }
168
169    public boolean hasImplicitRulesElement() { 
170      return this.implicitRules != null && !this.implicitRules.isEmpty();
171    }
172
173    public boolean hasImplicitRules() { 
174      return this.implicitRules != null && !this.implicitRules.isEmpty();
175    }
176
177    /**
178     * @param value {@link #implicitRules} (A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value
179     */
180    public Resource setImplicitRulesElement(UriType value) { 
181      this.implicitRules = value;
182      return this;
183    }
184
185    /**
186     * @return A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.
187     */
188    public String getImplicitRules() { 
189      return this.implicitRules == null ? null : this.implicitRules.getValue();
190    }
191
192    /**
193     * @param value A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.
194     */
195    public Resource setImplicitRules(String value) { 
196      if (Utilities.noString(value))
197        this.implicitRules = null;
198      else {
199        if (this.implicitRules == null)
200          this.implicitRules = new UriType();
201        this.implicitRules.setValue(value);
202      }
203      return this;
204    }
205
206    /**
207     * @return {@link #language} (The base language in which the resource is written.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
208     */
209    public CodeType getLanguageElement() { 
210      if (this.language == null)
211        if (Configuration.errorOnAutoCreate())
212          throw new Error("Attempt to auto-create Resource.language");
213        else if (Configuration.doAutoCreate())
214          this.language = new CodeType(); // bb
215      return this.language;
216    }
217
218    public boolean hasLanguageElement() { 
219      return this.language != null && !this.language.isEmpty();
220    }
221
222    public boolean hasLanguage() { 
223      return this.language != null && !this.language.isEmpty();
224    }
225
226    /**
227     * @param value {@link #language} (The base language in which the resource is written.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
228     */
229    public Resource setLanguageElement(CodeType value) { 
230      this.language = value;
231      return this;
232    }
233
234    /**
235     * @return The base language in which the resource is written.
236     */
237    public String getLanguage() { 
238      return this.language == null ? null : this.language.getValue();
239    }
240
241    /**
242     * @param value The base language in which the resource is written.
243     */
244    public Resource setLanguage(String value) { 
245      if (Utilities.noString(value))
246        this.language = null;
247      else {
248        if (this.language == null)
249          this.language = new CodeType();
250        this.language.setValue(value);
251      }
252      return this;
253    }
254
255      protected void listChildren(List<Property> childrenList) {
256        childrenList.add(new Property("id", "id", "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.", 0, java.lang.Integer.MAX_VALUE, id));
257        childrenList.add(new Property("meta", "Meta", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.", 0, java.lang.Integer.MAX_VALUE, meta));
258        childrenList.add(new Property("implicitRules", "uri", "A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.", 0, java.lang.Integer.MAX_VALUE, implicitRules));
259        childrenList.add(new Property("language", "code", "The base language in which the resource is written.", 0, java.lang.Integer.MAX_VALUE, language));
260      }
261
262      @Override
263      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
264        switch (hash) {
265        case 3355: /*id*/ return this.id == null ? new Base[0] : new Base[] {this.id}; // IdType
266        case 3347973: /*meta*/ return this.meta == null ? new Base[0] : new Base[] {this.meta}; // Meta
267        case -961826286: /*implicitRules*/ return this.implicitRules == null ? new Base[0] : new Base[] {this.implicitRules}; // UriType
268        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType
269        default: return super.getProperty(hash, name, checkValid);
270        }
271
272      }
273
274      @Override
275      public void setProperty(int hash, String name, Base value) throws FHIRException {
276        switch (hash) {
277        case 3355: // id
278          this.id = castToId(value); // IdType
279          break;
280        case 3347973: // meta
281          this.meta = castToMeta(value); // Meta
282          break;
283        case -961826286: // implicitRules
284          this.implicitRules = castToUri(value); // UriType
285          break;
286        case -1613589672: // language
287          this.language = castToCode(value); // CodeType
288          break;
289        default: super.setProperty(hash, name, value);
290        }
291
292      }
293
294      @Override
295      public void setProperty(String name, Base value) throws FHIRException {
296        if (name.equals("id"))
297          this.id = castToId(value); // IdType
298        else if (name.equals("meta"))
299          this.meta = castToMeta(value); // Meta
300        else if (name.equals("implicitRules"))
301          this.implicitRules = castToUri(value); // UriType
302        else if (name.equals("language"))
303          this.language = castToCode(value); // CodeType
304        else
305          super.setProperty(name, value);
306      }
307
308      @Override
309      public Base makeProperty(int hash, String name) throws FHIRException {
310        switch (hash) {
311        case 3355: throw new FHIRException("Cannot make property id as it is not a complex type"); // IdType
312        case 3347973:  return getMeta(); // Meta
313        case -961826286: throw new FHIRException("Cannot make property implicitRules as it is not a complex type"); // UriType
314        case -1613589672: throw new FHIRException("Cannot make property language as it is not a complex type"); // CodeType
315        default: return super.makeProperty(hash, name);
316        }
317
318      }
319
320      @Override
321      public Base addChild(String name) throws FHIRException {
322        if (name.equals("id")) {
323          throw new FHIRException("Cannot call addChild on a primitive type Resource.id");
324        }
325        else if (name.equals("meta")) {
326          this.meta = new Meta();
327          return this.meta;
328        }
329        else if (name.equals("implicitRules")) {
330          throw new FHIRException("Cannot call addChild on a primitive type Resource.implicitRules");
331        }
332        else if (name.equals("language")) {
333          throw new FHIRException("Cannot call addChild on a primitive type Resource.language");
334        }
335        else
336          return super.addChild(name);
337      }
338
339  public String fhirType() {
340    return "Resource";
341
342  }
343
344      public abstract Resource copy();
345
346      public void copyValues(Resource dst) {
347        dst.id = id == null ? null : id.copy();
348        dst.meta = meta == null ? null : meta.copy();
349        dst.implicitRules = implicitRules == null ? null : implicitRules.copy();
350        dst.language = language == null ? null : language.copy();
351      }
352
353      @Override
354      public boolean equalsDeep(Base other) {
355        if (!super.equalsDeep(other))
356          return false;
357        if (!(other instanceof Resource))
358          return false;
359        Resource o = (Resource) other;
360        return compareDeep(id, o.id, true) && compareDeep(meta, o.meta, true) && compareDeep(implicitRules, o.implicitRules, true)
361           && compareDeep(language, o.language, true);
362      }
363
364      @Override
365      public boolean equalsShallow(Base other) {
366        if (!super.equalsShallow(other))
367          return false;
368        if (!(other instanceof Resource))
369          return false;
370        Resource o = (Resource) other;
371        return compareValues(id, o.id, true) && compareValues(implicitRules, o.implicitRules, true) && compareValues(language, o.language, true)
372          ;
373      }
374
375      public boolean isEmpty() {
376        return super.isEmpty() && (id == null || id.isEmpty()) && (meta == null || meta.isEmpty()) && (implicitRules == null || implicitRules.isEmpty())
377           && (language == null || language.isEmpty());
378      }
379
380  public abstract ResourceType getResourceType();
381
382}
383