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