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