001package org.hl7.fhir.r5.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r5
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/*
024  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
053import java.util.ArrayList;
054import java.util.Date;
055import java.util.List;
056import org.hl7.fhir.exceptions.FHIRException;
057import org.hl7.fhir.instance.model.api.ICompositeType;
058
059import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
060import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
061import ca.uhn.fhir.model.api.annotation.Child;
062import ca.uhn.fhir.model.api.annotation.ChildOrder;
063import ca.uhn.fhir.model.api.annotation.DatatypeDef;
064import ca.uhn.fhir.model.api.annotation.Description;
065import ca.uhn.fhir.model.api.annotation.Block;
066/**
067 * Base definition for all elements that are defined inside a resource - but not those in a data type.
068 */
069@DatatypeDef(name="BackboneElement")
070public abstract class BackboneElement extends Element implements IBaseBackboneElement {
071
072    /**
073     * 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.
074
075Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).
076     */
077    @Child(name = "modifierExtension", type = {Extension.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=true)
078    @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)." )
079    protected List<Extension> modifierExtension;
080
081    private static final long serialVersionUID = -1431673179L;
082
083  /**
084   * Constructor
085   */
086    public BackboneElement() {
087      super();
088    }
089
090    /**
091     * @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.
092
093Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).)
094     */
095    public List<Extension> getModifierExtension() { 
096      if (this.modifierExtension == null)
097        this.modifierExtension = new ArrayList<Extension>();
098      return this.modifierExtension;
099    }
100
101    /**
102     * @return Returns a reference to <code>this</code> for easy method chaining
103     */
104    public BackboneElement setModifierExtension(List<Extension> theModifierExtension) { 
105      this.modifierExtension = theModifierExtension;
106      return this;
107    }
108
109    public boolean hasModifierExtension() { 
110      if (this.modifierExtension == null)
111        return false;
112      for (Extension item : this.modifierExtension)
113        if (!item.isEmpty())
114          return true;
115      return false;
116    }
117
118    public Extension addModifierExtension() { //3
119      Extension t = new Extension();
120      if (this.modifierExtension == null)
121        this.modifierExtension = new ArrayList<Extension>();
122      this.modifierExtension.add(t);
123      return t;
124    }
125
126    public BackboneElement addModifierExtension(Extension t) { //3
127      if (t == null)
128        return this;
129      if (this.modifierExtension == null)
130        this.modifierExtension = new ArrayList<Extension>();
131      this.modifierExtension.add(t);
132      return this;
133    }
134
135    /**
136     * @return The first repetition of repeating field {@link #modifierExtension}, creating it if it does not already exist
137     */
138    public Extension getModifierExtensionFirstRep() { 
139      if (getModifierExtension().isEmpty()) {
140        addModifierExtension();
141      }
142      return getModifierExtension().get(0);
143    }
144
145      protected void listChildren(List<Property> children) {
146        super.listChildren(children);
147        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));
148      }
149
150      @Override
151      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
152        switch (_hash) {
153        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);
154        default: return super.getNamedProperty(_hash, _name, _checkValid);
155        }
156
157      }
158
159      @Override
160      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
161        switch (hash) {
162        case -298878168: /*modifierExtension*/ return this.modifierExtension == null ? new Base[0] : this.modifierExtension.toArray(new Base[this.modifierExtension.size()]); // Extension
163        default: return super.getProperty(hash, name, checkValid);
164        }
165
166      }
167
168      @Override
169      public Base setProperty(int hash, String name, Base value) throws FHIRException {
170        switch (hash) {
171        case -298878168: // modifierExtension
172          this.getModifierExtension().add(castToExtension(value)); // Extension
173          return value;
174        default: return super.setProperty(hash, name, value);
175        }
176
177      }
178
179      @Override
180      public Base setProperty(String name, Base value) throws FHIRException {
181        if (name.equals("modifierExtension")) {
182          this.getModifierExtension().add(castToExtension(value));
183        } else
184          return super.setProperty(name, value);
185        return value;
186      }
187
188      @Override
189      public Base makeProperty(int hash, String name) throws FHIRException {
190        switch (hash) {
191        case -298878168:  return addModifierExtension(); 
192        default: return super.makeProperty(hash, name);
193        }
194
195      }
196
197      @Override
198      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
199        switch (hash) {
200        case -298878168: /*modifierExtension*/ return new String[] {"Extension"};
201        default: return super.getTypesForProperty(hash, name);
202        }
203
204      }
205
206      @Override
207      public Base addChild(String name) throws FHIRException {
208        if (name.equals("modifierExtension")) {
209          return addModifierExtension();
210        }
211        else
212          return super.addChild(name);
213      }
214
215  public String fhirType() {
216    return "BackboneElement";
217
218  }
219
220      public abstract BackboneElement copy();
221
222      public void copyValues(BackboneElement dst) {
223        super.copyValues(dst);
224        if (modifierExtension != null) {
225          dst.modifierExtension = new ArrayList<Extension>();
226          for (Extension i : modifierExtension)
227            dst.modifierExtension.add(i.copy());
228        };
229      }
230
231      @Override
232      public boolean equalsDeep(Base other_) {
233        if (!super.equalsDeep(other_))
234          return false;
235        if (!(other_ instanceof BackboneElement))
236          return false;
237        BackboneElement o = (BackboneElement) other_;
238        return compareDeep(modifierExtension, o.modifierExtension, true);
239      }
240
241      @Override
242      public boolean equalsShallow(Base other_) {
243        if (!super.equalsShallow(other_))
244          return false;
245        if (!(other_ instanceof BackboneElement))
246          return false;
247        BackboneElement o = (BackboneElement) other_;
248        return true;
249      }
250
251      public boolean isEmpty() {
252        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension);
253      }
254
255// added from java-adornments.txt:
256
257  public void checkNoModifiers(String noun, String verb) throws FHIRException {
258        if (hasModifierExtension()) {
259          throw new FHIRException("Found unknown Modifier Exceptions on "+noun+" doing "+verb);
260        }
261        
262  }
263
264// end addition
265
266}
267