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