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