001package org.hl7.fhir.dstu3.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 Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1 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 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. 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 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." ) 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 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.) 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> childrenList) { 119 childrenList.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)); 120 } 121 122 @Override 123 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 124 switch (hash) { 125 case -298878168: /*modifierExtension*/ return this.modifierExtension == null ? new Base[0] : this.modifierExtension.toArray(new Base[this.modifierExtension.size()]); // Extension 126 default: return super.getProperty(hash, name, checkValid); 127 } 128 129 } 130 131 @Override 132 public Base setProperty(int hash, String name, Base value) throws FHIRException { 133 switch (hash) { 134 case -298878168: // modifierExtension 135 this.getModifierExtension().add(castToExtension(value)); // Extension 136 return value; 137 default: return super.setProperty(hash, name, value); 138 } 139 140 } 141 142 @Override 143 public Base setProperty(String name, Base value) throws FHIRException { 144 if (name.equals("modifierExtension")) { 145 this.getModifierExtension().add(castToExtension(value)); 146 } else 147 return super.setProperty(name, value); 148 return value; 149 } 150 151 @Override 152 public Base makeProperty(int hash, String name) throws FHIRException { 153 switch (hash) { 154 case -298878168: return addModifierExtension(); 155 default: return super.makeProperty(hash, name); 156 } 157 158 } 159 160 @Override 161 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 162 switch (hash) { 163 case -298878168: /*modifierExtension*/ return new String[] {"Extension"}; 164 default: return super.getTypesForProperty(hash, name); 165 } 166 167 } 168 169 @Override 170 public Base addChild(String name) throws FHIRException { 171 if (name.equals("modifierExtension")) { 172 return addModifierExtension(); 173 } 174 else 175 return super.addChild(name); 176 } 177 178 public String fhirType() { 179 return "BackboneElement"; 180 181 } 182 183 public abstract BackboneElement copy(); 184 185 public void copyValues(BackboneElement dst) { 186 super.copyValues(dst); 187 if (modifierExtension != null) { 188 dst.modifierExtension = new ArrayList<Extension>(); 189 for (Extension i : modifierExtension) 190 dst.modifierExtension.add(i.copy()); 191 }; 192 } 193 194 @Override 195 public boolean equalsDeep(Base other) { 196 if (!super.equalsDeep(other)) 197 return false; 198 if (!(other instanceof BackboneElement)) 199 return false; 200 BackboneElement o = (BackboneElement) other; 201 return compareDeep(modifierExtension, o.modifierExtension, true); 202 } 203 204 @Override 205 public boolean equalsShallow(Base other) { 206 if (!super.equalsShallow(other)) 207 return false; 208 if (!(other instanceof BackboneElement)) 209 return false; 210 BackboneElement o = (BackboneElement) other; 211 return true; 212 } 213 214 public boolean isEmpty() { 215 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifierExtension); 216 } 217 218 219} 220