001package org.hl7.fhir.r5.tools;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.r5.tools.Enumerations.*;
038import org.hl7.fhir.exceptions.FHIRException;
039import org.hl7.fhir.r5.model.*;
040import org.hl7.fhir.instance.model.api.ICompositeType;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.ChildOrder;
043import ca.uhn.fhir.model.api.annotation.DatatypeDef;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046
047/**
048 * This is a concrete subtype of Base that has extensions (though the format in JSON is different)
049 */
050@DatatypeDef(name="CDSHooksExtensions")
051public class CDSHooksExtensions extends LogicalBase implements ICompositeType {
052
053    /**
054     * An extension where the name is defined by the extension definition, and the extension definition is of any type (including primitives, though the 'id' element cannot be represented for primitives)
055     */
056    @Child(name = "extension", type = {Base.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
057    @Description(shortDefinition="An extension of any type", formalDefinition="An extension where the name is defined by the extension definition, and the extension definition is of any type (including primitives, though the 'id' element cannot be represented for primitives)" )
058    protected List<NamedElementExtension> extensionList;
059
060    private static final long serialVersionUID = 163508525L;
061
062  /**
063   * Constructor
064   */
065    public CDSHooksExtensions() {
066      super();
067    }
068
069    /**
070     * @return {@link #extension} (An extension where the name is defined by the extension definition, and the extension definition is of any type (including primitives, though the 'id' element cannot be represented for primitives))
071     */
072    public List<NamedElementExtension> getExtensionList() { 
073      if (this.extensionList == null)
074        this.extensionList = new ArrayList<NamedElementExtension>();
075      return this.extensionList;
076    }
077
078    /**
079     * @return Returns a reference to <code>this</code> for easy method chaining
080     */
081    public CDSHooksExtensions setExtensionList(List<NamedElementExtension> theExtension) { 
082      this.extensionList = theExtension;
083      return this;
084    }
085
086    public boolean hasExtension() { 
087      if (this.extensionList == null)
088        return false;
089      for (NamedElementExtension item : this.extensionList)
090        if (!item.isEmpty())
091          return true;
092      return false;
093    }
094
095    public CDSHooksExtensions addExtension(NamedElementExtension t) { //3b
096      if (t == null)
097        return this;
098      if (this.extensionList == null)
099        this.extensionList = new ArrayList<NamedElementExtension>();
100      this.extensionList.add(t);
101      return this;
102    }
103
104      protected void listChildren(List<Property> children) {
105        super.listChildren(children);
106        children.add(new Property("extension", "Base", "An extension where the name is defined by the extension definition, and the extension definition is of any type (including primitives, though the 'id' element cannot be represented for primitives)", 0, java.lang.Integer.MAX_VALUE, extensionList));
107      }
108
109      @Override
110      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
111        switch (_hash) {
112        case -612557761: /*extension*/  return new Property("extension", "Base", "An extension where the name is defined by the extension definition, and the extension definition is of any type (including primitives, though the 'id' element cannot be represented for primitives)", 0, java.lang.Integer.MAX_VALUE, extensionList);
113        default: return super.getNamedProperty(_hash, _name, _checkValid);
114        }
115
116      }
117
118      @Override
119      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
120        switch (hash) {
121        case -612557761: /*extension*/ return this.extensionList == null ? new Base[0] : this.extensionList.toArray(new Base[this.extensionList.size()]); // NamedElementExtension
122        default: return super.getProperty(hash, name, checkValid);
123        }
124
125      }
126
127      @Override
128      public Base setProperty(int hash, String name, Base value) throws FHIRException {
129        switch (hash) {
130        case -612557761: // extension
131          this.getExtensionList().add((NamedElementExtension) value); // NamedElementExtension
132          return value;
133        default: return super.setProperty(hash, name, value);
134        }
135
136      }
137
138      @Override
139      public Base setProperty(String name, Base value) throws FHIRException {
140        if (name.equals("extension")) {
141          this.getExtensionList().add((NamedElementExtension) value); // NamedElementExtension
142        } else
143          return super.setProperty(name, value);
144        return value;
145      }
146
147      @Override
148      public Base makeProperty(int hash, String name) throws FHIRException {
149        switch (hash) {
150        case -612557761: /*div*/
151          throw new Error("Unable to make an instance of the abstract property 'extension'");
152        default: return super.makeProperty(hash, name);
153        }
154
155      }
156
157      @Override
158      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
159        switch (hash) {
160        case -612557761: /*extension*/ return new String[] {"Base"};
161        default: return super.getTypesForProperty(hash, name);
162        }
163
164      }
165
166      @Override
167      public Base addChild(String name) throws FHIRException {
168        if (name.equals("extension")) {
169          throw new FHIRException("Cannot call addChild on an abstract type CDSHooksExtensions.extension");
170        }
171        else
172          return super.addChild(name);
173      }
174
175  public String fhirType() {
176    return "CDSHooksExtensions";
177
178  }
179
180      public CDSHooksExtensions copy() {
181        CDSHooksExtensions dst = new CDSHooksExtensions();
182        copyValues(dst);
183        return dst;
184      }
185
186      public void copyValues(CDSHooksExtensions dst) {
187        super.copyValues(dst);
188        if (extensionList != null) {
189          dst.extensionList = new ArrayList<NamedElementExtension>();
190          for (NamedElementExtension i : extensionList)
191            dst.extensionList.add(i.copy());
192        };
193      }
194
195      protected CDSHooksExtensions typedCopy() {
196        return copy();
197      }
198
199      @Override
200      public boolean equalsDeep(Base other_) {
201        if (!super.equalsDeep(other_))
202          return false;
203        if (!(other_ instanceof CDSHooksExtensions))
204          return false;
205        CDSHooksExtensions o = (CDSHooksExtensions) other_;
206        return compareDeep(extensionList, o.extensionList, true);
207      }
208
209      @Override
210      public boolean equalsShallow(Base other_) {
211        if (!super.equalsShallow(other_))
212          return false;
213        if (!(other_ instanceof CDSHooksExtensions))
214          return false;
215        CDSHooksExtensions o = (CDSHooksExtensions) other_;
216        return true;
217      }
218
219      public boolean isEmpty() {
220        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(extensionList);
221      }
222
223
224}
225