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 Mon, Mar 5, 2018 18:26+1100 for FHIR v3.2.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 BackboneType extends Type 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 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. 070 */ 071 @Child(name = "modifierExtension", type = {Extension.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=true) 072 @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." ) 073 protected List<Extension> modifierExtension; 074 075 private static final long serialVersionUID = -1431673179L; 076 077 /** 078 * Constructor 079 */ 080 public BackboneType() { 081 super(); 082 } 083 084 /** 085 * @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 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.) 086 */ 087 public List<Extension> getModifierExtension() { 088 if (this.modifierExtension == null) 089 this.modifierExtension = new ArrayList<Extension>(); 090 return this.modifierExtension; 091 } 092 093 /** 094 * @return Returns a reference to <code>this</code> for easy method chaining 095 */ 096 public BackboneType setModifierExtension(List<Extension> theModifierExtension) { 097 this.modifierExtension = theModifierExtension; 098 return this; 099 } 100 101 public boolean hasModifierExtension() { 102 if (this.modifierExtension == null) 103 return false; 104 for (Extension item : this.modifierExtension) 105 if (!item.isEmpty()) 106 return true; 107 return false; 108 } 109 110 public Extension addModifierExtension() { //3 111 Extension t = new Extension(); 112 if (this.modifierExtension == null) 113 this.modifierExtension = new ArrayList<Extension>(); 114 this.modifierExtension.add(t); 115 return t; 116 } 117 118 public BackboneType addModifierExtension(Extension t) { //3 119 if (t == null) 120 return this; 121 if (this.modifierExtension == null) 122 this.modifierExtension = new ArrayList<Extension>(); 123 this.modifierExtension.add(t); 124 return this; 125 } 126 127 /** 128 * @return The first repetition of repeating field {@link #modifierExtension}, creating it if it does not already exist 129 */ 130 public Extension getModifierExtensionFirstRep() { 131 if (getModifierExtension().isEmpty()) { 132 addModifierExtension(); 133 } 134 return getModifierExtension().get(0); 135 } 136 137 protected void listChildren(List<Property> children) { 138 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 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.", 0, java.lang.Integer.MAX_VALUE, modifierExtension)); 139 } 140 141 @Override 142 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 143 switch (_hash) { 144 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 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.", 0, java.lang.Integer.MAX_VALUE, modifierExtension); 145 default: return super.getNamedProperty(_hash, _name, _checkValid); 146 } 147 148 } 149 150 @Override 151 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 152 switch (hash) { 153 case -298878168: /*modifierExtension*/ return this.modifierExtension == null ? new Base[0] : this.modifierExtension.toArray(new Base[this.modifierExtension.size()]); // Extension 154 default: return super.getProperty(hash, name, checkValid); 155 } 156 157 } 158 159 @Override 160 public Base setProperty(int hash, String name, Base value) throws FHIRException { 161 switch (hash) { 162 case -298878168: // modifierExtension 163 this.getModifierExtension().add(castToExtension(value)); // Extension 164 return value; 165 default: return super.setProperty(hash, name, value); 166 } 167 168 } 169 170 @Override 171 public Base setProperty(String name, Base value) throws FHIRException { 172 if (name.equals("modifierExtension")) { 173 this.getModifierExtension().add(castToExtension(value)); 174 } else 175 return super.setProperty(name, value); 176 return value; 177 } 178 179 @Override 180 public Base makeProperty(int hash, String name) throws FHIRException { 181 switch (hash) { 182 case -298878168: return addModifierExtension(); 183 default: return super.makeProperty(hash, name); 184 } 185 186 } 187 188 @Override 189 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 190 switch (hash) { 191 case -298878168: /*modifierExtension*/ return new String[] {"Extension"}; 192 default: return super.getTypesForProperty(hash, name); 193 } 194 195 } 196 197 @Override 198 public Base addChild(String name) throws FHIRException { 199 if (name.equals("modifierExtension")) { 200 return addModifierExtension(); 201 } 202 else 203 return super.addChild(name); 204 } 205 206 public String fhirType() { 207 return "BackboneElement"; 208 209 } 210 211 public abstract BackboneType copy(); 212 213 public void copyValues(BackboneType dst) { 214 super.copyValues(dst); 215 if (modifierExtension != null) { 216 dst.modifierExtension = new ArrayList<Extension>(); 217 for (Extension i : modifierExtension) 218 dst.modifierExtension.add(i.copy()); 219 }; 220 } 221 222 @Override 223 public boolean equalsDeep(Base other_) { 224 if (!super.equalsDeep(other_)) 225 return false; 226 if (!(other_ instanceof BackboneType)) 227 return false; 228 BackboneType o = (BackboneType) other_; 229 return compareDeep(modifierExtension, o.modifierExtension, true); 230 } 231 232 @Override 233 public boolean equalsShallow(Base other_) { 234 if (!super.equalsShallow(other_)) 235 return false; 236 if (!(other_ instanceof BackboneType)) 237 return false; 238 BackboneType o = (BackboneType) other_; 239 return true; 240 } 241 242 public boolean isEmpty() { 243 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension); 244 } 245 246// added from java-adornments.txt: 247 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// end addition 256 257} 258