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