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 ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.DatatypeDef;
043import ca.uhn.fhir.model.api.annotation.Block;
044import org.hl7.fhir.instance.model.api.*;
045import org.hl7.fhir.exceptions.FHIRException;
046/**
047 * Base definition for all elements that are defined inside a resource - but not those in a data type.
048 */
049@DatatypeDef(name="BackboneElement")
050public abstract class BackboneElement extends Element implements IBaseBackboneElement {
051
052    /**
053     * May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.
054
055Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).
056     */
057    @Child(name = "modifierExtension", type = {Extension.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=true)
058    @Description(shortDefinition="Extensions that cannot be ignored even if unrecognized", formalDefinition="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself)." )
059    protected List<Extension> modifierExtension;
060
061    private static final long serialVersionUID = -1431673179L;
062
063  /**
064   * Constructor
065   */
066    public BackboneElement() {
067      super();
068    }
069
070    /**
071     * @return {@link #modifierExtension} (May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.
072
073Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).)
074     */
075    public List<Extension> getModifierExtension() { 
076      if (this.modifierExtension == null)
077        this.modifierExtension = new ArrayList<Extension>();
078      return this.modifierExtension;
079    }
080
081    /**
082     * @return Returns a reference to <code>this</code> for easy method chaining
083     */
084    public BackboneElement setModifierExtension(List<Extension> theModifierExtension) { 
085      this.modifierExtension = theModifierExtension;
086      return this;
087    }
088
089    public boolean hasModifierExtension() { 
090      if (this.modifierExtension == null)
091        return false;
092      for (Extension item : this.modifierExtension)
093        if (!item.isEmpty())
094          return true;
095      return false;
096    }
097
098    public Extension addModifierExtension() { //3
099      Extension t = new Extension();
100      if (this.modifierExtension == null)
101        this.modifierExtension = new ArrayList<Extension>();
102      this.modifierExtension.add(t);
103      return t;
104    }
105
106    public BackboneElement addModifierExtension(Extension t) { //3
107      if (t == null)
108        return this;
109      if (this.modifierExtension == null)
110        this.modifierExtension = new ArrayList<Extension>();
111      this.modifierExtension.add(t);
112      return this;
113    }
114
115    /**
116     * @return The first repetition of repeating field {@link #modifierExtension}, creating it if it does not already exist
117     */
118    public Extension getModifierExtensionFirstRep() { 
119      if (getModifierExtension().isEmpty()) {
120        addModifierExtension();
121      }
122      return getModifierExtension().get(0);
123    }
124
125      protected void listChildren(List<Property> children) {
126        super.listChildren(children);
127        children.add(new Property("modifierExtension", "Extension", "May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).", 0, java.lang.Integer.MAX_VALUE, modifierExtension));
128      }
129
130      @Override
131      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
132        switch (_hash) {
133        case -298878168: /*modifierExtension*/  return new Property("modifierExtension", "Extension", "May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).", 0, java.lang.Integer.MAX_VALUE, modifierExtension);
134        default: return super.getNamedProperty(_hash, _name, _checkValid);
135        }
136
137      }
138
139      @Override
140      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
141        switch (hash) {
142        case -298878168: /*modifierExtension*/ return this.modifierExtension == null ? new Base[0] : this.modifierExtension.toArray(new Base[this.modifierExtension.size()]); // Extension
143        default: return super.getProperty(hash, name, checkValid);
144        }
145
146      }
147
148      @Override
149      public Base setProperty(int hash, String name, Base value) throws FHIRException {
150        switch (hash) {
151        case -298878168: // modifierExtension
152          this.getModifierExtension().add(castToExtension(value)); // Extension
153          return value;
154        default: return super.setProperty(hash, name, value);
155        }
156
157      }
158
159      @Override
160      public Base setProperty(String name, Base value) throws FHIRException {
161        if (name.equals("modifierExtension")) {
162          this.getModifierExtension().add(castToExtension(value));
163        } else
164          return super.setProperty(name, value);
165        return value;
166      }
167
168      @Override
169      public Base makeProperty(int hash, String name) throws FHIRException {
170        switch (hash) {
171        case -298878168:  return addModifierExtension(); 
172        default: return super.makeProperty(hash, name);
173        }
174
175      }
176
177      @Override
178      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
179        switch (hash) {
180        case -298878168: /*modifierExtension*/ return new String[] {"Extension"};
181        default: return super.getTypesForProperty(hash, name);
182        }
183
184      }
185
186      @Override
187      public Base addChild(String name) throws FHIRException {
188        if (name.equals("modifierExtension")) {
189          return addModifierExtension();
190        }
191        else
192          return super.addChild(name);
193      }
194
195  public String fhirType() {
196    return "BackboneElement";
197
198  }
199
200      public abstract BackboneElement copy();
201
202      public void copyValues(BackboneElement dst) {
203        super.copyValues(dst);
204        if (modifierExtension != null) {
205          dst.modifierExtension = new ArrayList<Extension>();
206          for (Extension i : modifierExtension)
207            dst.modifierExtension.add(i.copy());
208        };
209      }
210
211      @Override
212      public boolean equalsDeep(Base other_) {
213        if (!super.equalsDeep(other_))
214          return false;
215        if (!(other_ instanceof BackboneElement))
216          return false;
217        BackboneElement o = (BackboneElement) other_;
218        return compareDeep(modifierExtension, o.modifierExtension, true);
219      }
220
221      @Override
222      public boolean equalsShallow(Base other_) {
223        if (!super.equalsShallow(other_))
224          return false;
225        if (!(other_ instanceof BackboneElement))
226          return false;
227        BackboneElement o = (BackboneElement) other_;
228        return true;
229      }
230
231      public boolean isEmpty() {
232        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension);
233      }
234
235// added from java-adornments.txt:
236
237  public void checkNoModifiers(String noun, String verb) throws FHIRException {
238        if (hasModifierExtension()) {
239          throw new FHIRException("Found unknown Modifier Exceptions on "+noun+" doing "+verb);
240        }
241        
242  }
243
244// end addition
245
246}