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