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