001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import org.hl7.fhir.utilities.Utilities;
040import org.hl7.fhir.r4.model.Enumerations.*;
041import ca.uhn.fhir.model.api.annotation.ResourceDef;
042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.ChildOrder;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047import org.hl7.fhir.instance.model.api.*;
048import org.hl7.fhir.exceptions.FHIRException;
049/**
050 * This is the base resource type for everything.
051 */
052public abstract class Resource extends BaseResource implements IAnyResource {
053
054    /**
055     * The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
056     */
057    @Child(name = "id", type = {IdType.class}, order=0, min=0, max=1, modifier=false, summary=true)
058    @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." )
059    protected IdType id;
060
061    /**
062     * The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.
063     */
064    @Child(name = "meta", type = {Meta.class}, order=1, min=0, max=1, modifier=false, summary=true)
065    @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 might not always be associated with version changes to the resource." )
066    protected Meta meta;
067
068    /**
069     * A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.
070     */
071    @Child(name = "implicitRules", type = {UriType.class}, order=2, min=0, max=1, modifier=true, summary=true)
072    @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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc." )
073    protected UriType implicitRules;
074
075    /**
076     * The base language in which the resource is written.
077     */
078    @Child(name = "language", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=false)
079    @Description(shortDefinition="Language of the resource content", formalDefinition="The base language in which the resource is written." )
080    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/languages")
081    protected CodeType language;
082
083    private static final long serialVersionUID = -559462759L;
084
085  /**
086   * Constructor
087   */
088    public Resource() {
089      super();
090    }
091
092    /**
093     * @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
094     */
095    public IdType getIdElement() { 
096      if (this.id == null)
097        if (Configuration.errorOnAutoCreate())
098          throw new Error("Attempt to auto-create Resource.id");
099        else if (Configuration.doAutoCreate())
100          this.id = new IdType(); // bb
101      return this.id;
102    }
103
104    public boolean hasIdElement() { 
105      return this.id != null && !this.id.isEmpty();
106    }
107
108    public boolean hasId() { 
109      return this.id != null && !this.id.isEmpty();
110    }
111
112    /**
113     * @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
114     */
115    public Resource setIdElement(IdType value) { 
116      this.id = value;
117      return this;
118    }
119
120    /**
121     * @return The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
122     */
123    public String getId() { 
124      return this.id == null ? null : this.id.getValue();
125    }
126
127    /**
128     * @param value The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.
129     */
130    public Resource setId(String value) { 
131      if (Utilities.noString(value))
132        this.id = null;
133      else {
134        if (this.id == null)
135          this.id = new IdType();
136        this.id.setValue(value);
137      }
138      return this;
139    }
140
141    /**
142     * @return {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.)
143     */
144    public Meta getMeta() { 
145      if (this.meta == null)
146        if (Configuration.errorOnAutoCreate())
147          throw new Error("Attempt to auto-create Resource.meta");
148        else if (Configuration.doAutoCreate())
149          this.meta = new Meta(); // cc
150      return this.meta;
151    }
152
153    public boolean hasMeta() { 
154      return this.meta != null && !this.meta.isEmpty();
155    }
156
157    /**
158     * @param value {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.)
159     */
160    public Resource setMeta(Meta value) { 
161      this.meta = value;
162      return this;
163    }
164
165    /**
166     * @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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value
167     */
168    public UriType getImplicitRulesElement() { 
169      if (this.implicitRules == null)
170        if (Configuration.errorOnAutoCreate())
171          throw new Error("Attempt to auto-create Resource.implicitRules");
172        else if (Configuration.doAutoCreate())
173          this.implicitRules = new UriType(); // bb
174      return this.implicitRules;
175    }
176
177    public boolean hasImplicitRulesElement() { 
178      return this.implicitRules != null && !this.implicitRules.isEmpty();
179    }
180
181    public boolean hasImplicitRules() { 
182      return this.implicitRules != null && !this.implicitRules.isEmpty();
183    }
184
185    /**
186     * @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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value
187     */
188    public Resource setImplicitRulesElement(UriType value) { 
189      this.implicitRules = value;
190      return this;
191    }
192
193    /**
194     * @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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.
195     */
196    public String getImplicitRules() { 
197      return this.implicitRules == null ? null : this.implicitRules.getValue();
198    }
199
200    /**
201     * @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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.
202     */
203    public Resource setImplicitRules(String value) { 
204      if (Utilities.noString(value))
205        this.implicitRules = null;
206      else {
207        if (this.implicitRules == null)
208          this.implicitRules = new UriType();
209        this.implicitRules.setValue(value);
210      }
211      return this;
212    }
213
214    /**
215     * @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
216     */
217    public CodeType getLanguageElement() { 
218      if (this.language == null)
219        if (Configuration.errorOnAutoCreate())
220          throw new Error("Attempt to auto-create Resource.language");
221        else if (Configuration.doAutoCreate())
222          this.language = new CodeType(); // bb
223      return this.language;
224    }
225
226    public boolean hasLanguageElement() { 
227      return this.language != null && !this.language.isEmpty();
228    }
229
230    public boolean hasLanguage() { 
231      return this.language != null && !this.language.isEmpty();
232    }
233
234    /**
235     * @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
236     */
237    public Resource setLanguageElement(CodeType value) { 
238      this.language = value;
239      return this;
240    }
241
242    /**
243     * @return The base language in which the resource is written.
244     */
245    public String getLanguage() { 
246      return this.language == null ? null : this.language.getValue();
247    }
248
249    /**
250     * @param value The base language in which the resource is written.
251     */
252    public Resource setLanguage(String value) { 
253      if (Utilities.noString(value))
254        this.language = null;
255      else {
256        if (this.language == null)
257          this.language = new CodeType();
258        this.language.setValue(value);
259      }
260      return this;
261    }
262
263      protected void listChildren(List<Property> children) {
264        children.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, 1, id));
265        children.add(new Property("meta", "Meta", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.", 0, 1, meta));
266        children.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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", 0, 1, implicitRules));
267        children.add(new Property("language", "code", "The base language in which the resource is written.", 0, 1, language));
268      }
269
270      @Override
271      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
272        switch (_hash) {
273        case 3355: /*id*/  return 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, 1, id);
274        case 3347973: /*meta*/  return new Property("meta", "Meta", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.", 0, 1, meta);
275        case -961826286: /*implicitRules*/  return 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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", 0, 1, implicitRules);
276        case -1613589672: /*language*/  return new Property("language", "code", "The base language in which the resource is written.", 0, 1, language);
277        default: return super.getNamedProperty(_hash, _name, _checkValid);
278        }
279
280      }
281
282      @Override
283      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
284        switch (hash) {
285        case 3355: /*id*/ return this.id == null ? new Base[0] : new Base[] {this.id}; // IdType
286        case 3347973: /*meta*/ return this.meta == null ? new Base[0] : new Base[] {this.meta}; // Meta
287        case -961826286: /*implicitRules*/ return this.implicitRules == null ? new Base[0] : new Base[] {this.implicitRules}; // UriType
288        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType
289        default: return super.getProperty(hash, name, checkValid);
290        }
291
292      }
293
294      @Override
295      public Base setProperty(int hash, String name, Base value) throws FHIRException {
296        switch (hash) {
297        case 3355: // id
298          this.id = castToId(value); // IdType
299          return value;
300        case 3347973: // meta
301          this.meta = castToMeta(value); // Meta
302          return value;
303        case -961826286: // implicitRules
304          this.implicitRules = castToUri(value); // UriType
305          return value;
306        case -1613589672: // language
307          this.language = castToCode(value); // CodeType
308          return value;
309        default: return super.setProperty(hash, name, value);
310        }
311
312      }
313
314      @Override
315      public Base setProperty(String name, Base value) throws FHIRException {
316        if (name.equals("id")) {
317          this.id = castToId(value); // IdType
318        } else if (name.equals("meta")) {
319          this.meta = castToMeta(value); // Meta
320        } else if (name.equals("implicitRules")) {
321          this.implicitRules = castToUri(value); // UriType
322        } else if (name.equals("language")) {
323          this.language = castToCode(value); // CodeType
324        } else
325          return super.setProperty(name, value);
326        return value;
327      }
328
329      @Override
330      public Base makeProperty(int hash, String name) throws FHIRException {
331        switch (hash) {
332        case 3355:  return getIdElement();
333        case 3347973:  return getMeta(); 
334        case -961826286:  return getImplicitRulesElement();
335        case -1613589672:  return getLanguageElement();
336        default: return super.makeProperty(hash, name);
337        }
338
339      }
340
341      @Override
342      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
343        switch (hash) {
344        case 3355: /*id*/ return new String[] {"id"};
345        case 3347973: /*meta*/ return new String[] {"Meta"};
346        case -961826286: /*implicitRules*/ return new String[] {"uri"};
347        case -1613589672: /*language*/ return new String[] {"code"};
348        default: return super.getTypesForProperty(hash, name);
349        }
350
351      }
352
353      @Override
354      public Base addChild(String name) throws FHIRException {
355        if (name.equals("id")) {
356          throw new FHIRException("Cannot call addChild on a primitive type Resource.id");
357        }
358        else if (name.equals("meta")) {
359          this.meta = new Meta();
360          return this.meta;
361        }
362        else if (name.equals("implicitRules")) {
363          throw new FHIRException("Cannot call addChild on a primitive type Resource.implicitRules");
364        }
365        else if (name.equals("language")) {
366          throw new FHIRException("Cannot call addChild on a primitive type Resource.language");
367        }
368        else
369          return super.addChild(name);
370      }
371
372  public String fhirType() {
373    return "Resource";
374
375  }
376
377      public abstract Resource copy();
378
379      public void copyValues(Resource dst) {
380        dst.id = id == null ? null : id.copy();
381        dst.meta = meta == null ? null : meta.copy();
382        dst.implicitRules = implicitRules == null ? null : implicitRules.copy();
383        dst.language = language == null ? null : language.copy();
384      }
385
386      @Override
387      public boolean equalsDeep(Base other_) {
388        if (!super.equalsDeep(other_))
389          return false;
390        if (!(other_ instanceof Resource))
391          return false;
392        Resource o = (Resource) other_;
393        return compareDeep(id, o.id, true) && compareDeep(meta, o.meta, true) && compareDeep(implicitRules, o.implicitRules, true)
394           && compareDeep(language, o.language, true);
395      }
396
397      @Override
398      public boolean equalsShallow(Base other_) {
399        if (!super.equalsShallow(other_))
400          return false;
401        if (!(other_ instanceof Resource))
402          return false;
403        Resource o = (Resource) other_;
404        return compareValues(id, o.id, true) && compareValues(implicitRules, o.implicitRules, true) && compareValues(language, o.language, true)
405          ;
406      }
407
408      public boolean isEmpty() {
409        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(id, meta, implicitRules
410          , language);
411      }
412
413
414  @Override
415  public String getIdBase() {
416    return getId();
417  }
418  
419  @Override
420  public void setIdBase(String value) {
421    setId(value);
422  }
423  public abstract ResourceType getResourceType();
424// added from java-adornments.txt:
425
426  public String getLanguage(String defValue) {
427    return hasLanguage() ? getLanguage() : defValue;
428  }
429
430
431// end addition
432
433}