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 Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0 033 034import java.util.*; 035 036import ca.uhn.fhir.model.api.annotation.Child; 037import ca.uhn.fhir.model.api.annotation.ChildOrder; 038import ca.uhn.fhir.model.api.annotation.Description; 039import ca.uhn.fhir.model.api.annotation.DatatypeDef; 040import ca.uhn.fhir.model.api.annotation.Block; 041import org.hl7.fhir.instance.model.api.*; 042import org.hl7.fhir.exceptions.FHIRException; 043/** 044 * Base definition for all elements that are defined inside a resource - but not those in a data type. 045 */ 046@DatatypeDef(name="BackboneElement") 047public abstract class BackboneElement extends Element implements IBaseBackboneElement { 048 049 /** 050 * 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. 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. 051 052Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself). 053 */ 054 @Child(name = "modifierExtension", type = {Extension.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=true) 055 @Description(shortDefinition="Extensions that cannot be ignored 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. 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)." ) 056 protected List<Extension> modifierExtension; 057 058 private static final long serialVersionUID = -1431673179L; 059 060 /** 061 * Constructor 062 */ 063 public BackboneElement() { 064 super(); 065 } 066 067 /** 068 * @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. 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. 069 070Modifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).) 071 */ 072 public List<Extension> getModifierExtension() { 073 if (this.modifierExtension == null) 074 this.modifierExtension = new ArrayList<Extension>(); 075 return this.modifierExtension; 076 } 077 078 /** 079 * @return Returns a reference to <code>this</code> for easy method chaining 080 */ 081 public BackboneElement setModifierExtension(List<Extension> theModifierExtension) { 082 this.modifierExtension = theModifierExtension; 083 return this; 084 } 085 086 public boolean hasModifierExtension() { 087 if (this.modifierExtension == null) 088 return false; 089 for (Extension item : this.modifierExtension) 090 if (!item.isEmpty()) 091 return true; 092 return false; 093 } 094 095 public Extension addModifierExtension() { //3 096 Extension t = new Extension(); 097 if (this.modifierExtension == null) 098 this.modifierExtension = new ArrayList<Extension>(); 099 this.modifierExtension.add(t); 100 return t; 101 } 102 103 public BackboneElement addModifierExtension(Extension t) { //3 104 if (t == null) 105 return this; 106 if (this.modifierExtension == null) 107 this.modifierExtension = new ArrayList<Extension>(); 108 this.modifierExtension.add(t); 109 return this; 110 } 111 112 /** 113 * @return The first repetition of repeating field {@link #modifierExtension}, creating it if it does not already exist 114 */ 115 public Extension getModifierExtensionFirstRep() { 116 if (getModifierExtension().isEmpty()) { 117 addModifierExtension(); 118 } 119 return getModifierExtension().get(0); 120 } 121 122 protected void listChildren(List<Property> children) { 123 super.listChildren(children); 124 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. 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)); 125 } 126 127 @Override 128 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 129 switch (_hash) { 130 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. 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); 131 default: return super.getNamedProperty(_hash, _name, _checkValid); 132 } 133 134 } 135 136 @Override 137 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 138 switch (hash) { 139 case -298878168: /*modifierExtension*/ return this.modifierExtension == null ? new Base[0] : this.modifierExtension.toArray(new Base[this.modifierExtension.size()]); // Extension 140 default: return super.getProperty(hash, name, checkValid); 141 } 142 143 } 144 145 @Override 146 public Base setProperty(int hash, String name, Base value) throws FHIRException { 147 switch (hash) { 148 case -298878168: // modifierExtension 149 this.getModifierExtension().add(castToExtension(value)); // Extension 150 return value; 151 default: return super.setProperty(hash, name, value); 152 } 153 154 } 155 156 @Override 157 public Base setProperty(String name, Base value) throws FHIRException { 158 if (name.equals("modifierExtension")) { 159 this.getModifierExtension().add(castToExtension(value)); 160 } else 161 return super.setProperty(name, value); 162 return value; 163 } 164 165 @Override 166 public Base makeProperty(int hash, String name) throws FHIRException { 167 switch (hash) { 168 case -298878168: return addModifierExtension(); 169 default: return super.makeProperty(hash, name); 170 } 171 172 } 173 174 @Override 175 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 176 switch (hash) { 177 case -298878168: /*modifierExtension*/ return new String[] {"Extension"}; 178 default: return super.getTypesForProperty(hash, name); 179 } 180 181 } 182 183 @Override 184 public Base addChild(String name) throws FHIRException { 185 if (name.equals("modifierExtension")) { 186 return addModifierExtension(); 187 } 188 else 189 return super.addChild(name); 190 } 191 192 public String fhirType() { 193 return "BackboneElement"; 194 195 } 196 197 public abstract BackboneElement copy(); 198 199 public void copyValues(BackboneElement dst) { 200 super.copyValues(dst); 201 if (modifierExtension != null) { 202 dst.modifierExtension = new ArrayList<Extension>(); 203 for (Extension i : modifierExtension) 204 dst.modifierExtension.add(i.copy()); 205 }; 206 } 207 208 @Override 209 public boolean equalsDeep(Base other_) { 210 if (!super.equalsDeep(other_)) 211 return false; 212 if (!(other_ instanceof BackboneElement)) 213 return false; 214 BackboneElement o = (BackboneElement) other_; 215 return compareDeep(modifierExtension, o.modifierExtension, true); 216 } 217 218 @Override 219 public boolean equalsShallow(Base other_) { 220 if (!super.equalsShallow(other_)) 221 return false; 222 if (!(other_ instanceof BackboneElement)) 223 return false; 224 BackboneElement o = (BackboneElement) other_; 225 return true; 226 } 227 228 public boolean isEmpty() { 229 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension); 230 } 231 232// added from java-adornments.txt: 233 234 public void checkNoModifiers(String noun, String verb) throws FHIRException { 235 if (hasModifierExtension()) { 236 throw new FHIRException("Found unknown Modifier Exceptions on "+noun+" doing "+verb); 237 } 238 239 } 240 241// end addition 242 243} 244