![](/hapi-fhir/images/logos/raccoon-forwards.png)
001package org.hl7.fhir.r5.model; 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.model.Enumerations.*; 038import org.hl7.fhir.utilities.Utilities; 039import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; 040import org.hl7.fhir.exceptions.FHIRException; 041import org.hl7.fhir.instance.model.api.ICompositeType; 042import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 043import ca.uhn.fhir.model.api.annotation.Child; 044import ca.uhn.fhir.model.api.annotation.ChildOrder; 045import ca.uhn.fhir.model.api.annotation.DatatypeDef; 046import ca.uhn.fhir.model.api.annotation.Description; 047import ca.uhn.fhir.model.api.annotation.Block; 048 049/** 050 * BackboneType Type: Base definition for the few data types that are allowed to carry modifier extensions. 051 */ 052@DatatypeDef(name="BackboneType") 053public abstract class BackboneType extends DataType implements IBaseBackboneElement { 054 055 /** 056 * 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 managable, 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. 057 058Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself). 059 */ 060 @Child(name = "modifierExtension", type = {Extension.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=true) 061 @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 managable, 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)." ) 062 protected List<Extension> modifierExtension; 063 064 private static final long serialVersionUID = -1431673179L; 065 066 /** 067 * Constructor 068 */ 069 public BackboneType() { 070 super(); 071 } 072 073 /** 074 * @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 managable, 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. 075 076Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).) 077 */ 078 public List<Extension> getModifierExtension() { 079 if (this.modifierExtension == null) 080 this.modifierExtension = new ArrayList<Extension>(); 081 return this.modifierExtension; 082 } 083 084 /** 085 * @return Returns a reference to <code>this</code> for easy method chaining 086 */ 087 public BackboneType setModifierExtension(List<Extension> theModifierExtension) { 088 this.modifierExtension = theModifierExtension; 089 return this; 090 } 091 092 public boolean hasModifierExtension() { 093 if (this.modifierExtension == null) 094 return false; 095 for (Extension item : this.modifierExtension) 096 if (!item.isEmpty()) 097 return true; 098 return false; 099 } 100 101 public Extension addModifierExtension() { //3 102 Extension t = new Extension(); 103 if (this.modifierExtension == null) 104 this.modifierExtension = new ArrayList<Extension>(); 105 this.modifierExtension.add(t); 106 return t; 107 } 108 109 public BackboneType addModifierExtension(Extension t) { //3 110 if (t == null) 111 return this; 112 if (this.modifierExtension == null) 113 this.modifierExtension = new ArrayList<Extension>(); 114 this.modifierExtension.add(t); 115 return this; 116 } 117 118 /** 119 * @return The first repetition of repeating field {@link #modifierExtension}, creating it if it does not already exist {3} 120 */ 121 public Extension getModifierExtensionFirstRep() { 122 if (getModifierExtension().isEmpty()) { 123 addModifierExtension(); 124 } 125 return getModifierExtension().get(0); 126 } 127 128 protected void listChildren(List<Property> children) { 129 super.listChildren(children); 130 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 managable, 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)); 131 } 132 133 @Override 134 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 135 switch (_hash) { 136 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 managable, 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); 137 default: return super.getNamedProperty(_hash, _name, _checkValid); 138 } 139 140 } 141 142 @Override 143 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 144 switch (hash) { 145 case -298878168: /*modifierExtension*/ return this.modifierExtension == null ? new Base[0] : this.modifierExtension.toArray(new Base[this.modifierExtension.size()]); // Extension 146 default: return super.getProperty(hash, name, checkValid); 147 } 148 149 } 150 151 @Override 152 public Base setProperty(int hash, String name, Base value) throws FHIRException { 153 switch (hash) { 154 case -298878168: // modifierExtension 155 this.getModifierExtension().add(TypeConvertor.castToExtension(value)); // Extension 156 return value; 157 default: return super.setProperty(hash, name, value); 158 } 159 160 } 161 162 @Override 163 public Base setProperty(String name, Base value) throws FHIRException { 164 if (name.equals("modifierExtension")) { 165 this.getModifierExtension().add(TypeConvertor.castToExtension(value)); 166 } else 167 return super.setProperty(name, value); 168 return value; 169 } 170 171 @Override 172 public void removeChild(String name, Base value) throws FHIRException { 173 if (name.equals("modifierExtension")) { 174 this.getModifierExtension().remove(value); 175 } else 176 super.removeChild(name, value); 177 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 "BackboneType"; 209 210 } 211 212 public abstract BackboneType copy(); 213 214 public void copyValues(BackboneType 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 BackboneType)) 228 return false; 229 BackboneType o = (BackboneType) 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 BackboneType)) 238 return false; 239 BackboneType o = (BackboneType) other_; 240 return true; 241 } 242 243 public boolean isEmpty() { 244 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension); 245 } 246 247 // Manual code (from Configuration.txt): 248 public void checkNoModifiers(String noun, String verb) throws FHIRException { 249 if (hasModifierExtension()) { 250 throw new FHIRException("Found unknown Modifier Exceptions on "+noun+" doing "+verb); 251 } 252 253 } 254 255 256 public void copyExtensions(org.hl7.fhir.r5.model.BackboneElement src, String... urls) { 257 super.copyExtensions(src,urls); 258 for (Extension e : src.getModifierExtension()) { 259 if (Utilities.existsInList(e.getUrl(), urls)) { 260 addModifierExtension(e.copy()); 261 } 262 } 263 } 264 265 public List<Extension> getExtensionsByUrl(String... theUrls) { 266 267 ArrayList<Extension> retVal = new ArrayList<>(); 268 for (Extension next : getModifierExtension()) { 269 if (Utilities.existsInList(next.getUrl(), theUrls)) { 270 retVal.add(next); 271 } 272 } 273 retVal.addAll(super.getExtensionsByUrl(theUrls)); 274 return java.util.Collections.unmodifiableList(retVal); 275 } 276 277 278 public boolean hasExtension(String... theUrls) { 279 for (Extension next : getModifierExtension()) { 280 if (Utilities.existsInList(next.getUrl(), theUrls)) { 281 return true; 282 } 283 } 284 return super.hasExtension(theUrls); 285 } 286 287 288 public boolean hasExtension(String theUrl) { 289 for (Extension ext : getModifierExtension()) { 290 if (theUrl.equals(ext.getUrl())) { 291 return true; 292 } 293 } 294 295 return super.hasExtension(theUrl); 296 } 297 298 299 public void copyNewExtensions(org.hl7.fhir.r5.model.BackboneElement src, String... urls) { 300 for (Extension e : src.getModifierExtension()) { 301 if (Utilities.existsInList(e.getUrl(), urls) && !!hasExtension(e.getUrl())) { 302 addExtension(e.copy()); 303 } 304 } 305 super.copyNewExtensions(src, urls); 306 } 307 // end addition 308 309} 310