
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 Mon, Mar 5, 2018 18:26+1100 for FHIR v3.2.0 033import java.util.ArrayList; 034import java.util.List; 035 036import org.hl7.fhir.exceptions.FHIRException; 037import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 038import org.hl7.fhir.utilities.Utilities; 039 040import ca.uhn.fhir.model.api.annotation.Child; 041import ca.uhn.fhir.model.api.annotation.DatatypeDef; 042import ca.uhn.fhir.model.api.annotation.Description; 043 044/** 045 * Base definition for all elements that are defined inside a resource - but not 046 * those in a data type. 047 */ 048@DatatypeDef(name = "BackboneElement") 049public abstract class BackboneType extends Type implements IBaseBackboneElement { 050 051 /** 052 * May be used to represent additional information that is not part of the basic 053 * definition of the element, and that modifies the understanding of the element 054 * that contains it. Usually modifier elements provide negation or 055 * qualification. In order to make the use of extensions safe and manageable, 056 * there is a strict set of governance applied to the definition and use of 057 * extensions. Though any implementer is allowed to define an extension, there 058 * is a set of requirements that SHALL be met as part of the definition of the 059 * extension. Applications processing a resource are required to check for 060 * modifier extensions. 061 */ 062 @Child(name = "modifierExtension", type = { 063 Extension.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = true, summary = true) 064 @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.") 065 protected List<Extension> modifierExtension; 066 067 private static final long serialVersionUID = -1431673179L; 068 069 /** 070 * Constructor 071 */ 072 public BackboneType() { 073 super(); 074 } 075 076 /** 077 * @return {@link #modifierExtension} (May be used to represent additional 078 * information that is not part of the basic definition of the element, 079 * and that modifies the understanding of the element that contains it. 080 * Usually modifier elements provide negation or qualification. In order 081 * to make the use of extensions safe and manageable, there is a strict 082 * set of governance applied to the definition and use of extensions. 083 * Though any implementer is allowed to define an extension, there is a 084 * set of requirements that SHALL be met as part of the definition of 085 * the extension. Applications processing a resource are required to 086 * 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 BackboneType 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 BackboneType 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}, 130 * creating it if it does not already exist 131 */ 132 public Extension getModifierExtensionFirstRep() { 133 if (getModifierExtension().isEmpty()) { 134 addModifierExtension(); 135 } 136 return getModifierExtension().get(0); 137 } 138 139 protected void listChildren(List<Property> children) { 140 children.add(new Property("modifierExtension", "Extension", 141 "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.", 142 0, java.lang.Integer.MAX_VALUE, modifierExtension)); 143 } 144 145 @Override 146 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 147 switch (_hash) { 148 case -298878168: 149 /* modifierExtension */ return 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 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.", 151 0, java.lang.Integer.MAX_VALUE, modifierExtension); 152 default: 153 return super.getNamedProperty(_hash, _name, _checkValid); 154 } 155 156 } 157 158 @Override 159 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 160 switch (hash) { 161 case -298878168: 162 /* modifierExtension */ return this.modifierExtension == null ? new Base[0] 163 : this.modifierExtension.toArray(new Base[this.modifierExtension.size()]); // Extension 164 default: 165 return super.getProperty(hash, name, checkValid); 166 } 167 168 } 169 170 @Override 171 public Base setProperty(int hash, String name, Base value) throws FHIRException { 172 switch (hash) { 173 case -298878168: // modifierExtension 174 this.getModifierExtension().add(castToExtension(value)); // Extension 175 return value; 176 default: 177 return super.setProperty(hash, name, value); 178 } 179 180 } 181 182 @Override 183 public Base setProperty(String name, Base value) throws FHIRException { 184 if (name.equals("modifierExtension")) { 185 this.getModifierExtension().add(castToExtension(value)); 186 } else 187 return super.setProperty(name, value); 188 return value; 189 } 190 191 @Override 192 public void removeChild(String name, Base value) throws FHIRException { 193 if (name.equals("modifierExtension")) { 194 this.getModifierExtension().remove(castToExtension(value)); 195 } else 196 super.removeChild(name, value); 197 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 BackboneType copy(); 236 237 public void copyValues(BackboneType 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 BackboneType)) 252 return false; 253 BackboneType o = (BackboneType) 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 BackboneType)) 262 return false; 263 BackboneType o = (BackboneType) 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 public void copyExtensions(org.hl7.fhir.r4.model.BackboneElement src, String... urls) { 280 super.copyExtensions(src,urls); 281 for (Extension e : src.getModifierExtension()) { 282 if (Utilities.existsInList(e.getUrl(), urls)) { 283 addModifierExtension(e.copy()); 284 } 285 } 286 } 287 288 public List<Extension> getExtensionsByUrl(String... theUrls) { 289 290 ArrayList<Extension> retVal = new ArrayList<>(); 291 for (Extension next : getModifierExtension()) { 292 if (Utilities.existsInList(next.getUrl(), theUrls)) { 293 retVal.add(next); 294 } 295 } 296 retVal.addAll(super.getExtensionsByUrl(theUrls)); 297 return java.util.Collections.unmodifiableList(retVal); 298 } 299 300 301 public boolean hasExtension(String... theUrls) { 302 for (Extension next : getModifierExtension()) { 303 if (Utilities.existsInList(next.getUrl(), theUrls)) { 304 return true; 305 } 306 } 307 return super.hasExtension(theUrls); 308 } 309 310 311 public boolean hasExtension(String theUrl) { 312 for (Extension ext : getModifierExtension()) { 313 if (theUrl.equals(ext.getUrl())) { 314 return true; 315 } 316 } 317 318 return super.hasExtension(theUrl); 319 } 320 321 322 public void copyNewExtensions(org.hl7.fhir.r4.model.BackboneElement src, String... urls) { 323 for (Extension e : src.getModifierExtension()) { 324 if (Utilities.existsInList(e.getUrl(), urls) && !!hasExtension(e.getUrl())) { 325 addExtension(e.copy()); 326 } 327 } 328 super.copyNewExtensions(src, urls); 329 } 330 // end addition 331 332}