001package org.hl7.fhir.dstu2.model; 002 003 004 005 006/* 007 Copyright (c) 2011+, HL7, Inc. 008 All rights reserved. 009 010 Redistribution and use in source and binary forms, with or without modification, 011 are permitted provided that the following conditions are met: 012 013 * Redistributions of source code must retain the above copyright notice, this 014 list of conditions and the following disclaimer. 015 * Redistributions in binary form must reproduce the above copyright notice, 016 this list of conditions and the following disclaimer in the documentation 017 and/or other materials provided with the distribution. 018 * Neither the name of HL7 nor the names of its contributors may be used to 019 endorse or promote products derived from this software without specific 020 prior written permission. 021 022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 025 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 026 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 027 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 028 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 029 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 030 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 031 POSSIBILITY OF SUCH DAMAGE. 032 033*/ 034 035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 036import java.util.List; 037 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.Description; 040import org.hl7.fhir.instance.model.api.IAnyResource; 041import org.hl7.fhir.exceptions.FHIRException; 042import org.hl7.fhir.utilities.Utilities; 043/** 044 * This is the base resource type for everything. 045 */ 046public abstract class Resource extends BaseResource implements IAnyResource { 047 048 /** 049 * The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. 050 */ 051 @Child(name = "id", type = {IdType.class}, order=0, min=0, max=1, modifier=false, summary=true) 052 @Description(shortDefinition="Logical id of this artifact", formalDefinition="The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes." ) 053 protected IdType id; 054 055 /** 056 * The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource. 057 */ 058 @Child(name = "meta", type = {Meta.class}, order=1, min=0, max=1, modifier=false, summary=true) 059 @Description(shortDefinition="Metadata about the resource", formalDefinition="The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource." ) 060 protected Meta meta; 061 062 /** 063 * A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. 064 */ 065 @Child(name = "implicitRules", type = {UriType.class}, order=2, min=0, max=1, modifier=true, summary=true) 066 @Description(shortDefinition="A set of rules under which this content was created", formalDefinition="A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content." ) 067 protected UriType implicitRules; 068 069 /** 070 * The base language in which the resource is written. 071 */ 072 @Child(name = "language", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=false) 073 @Description(shortDefinition="Language of the resource content", formalDefinition="The base language in which the resource is written." ) 074 protected CodeType language; 075 076 private static final long serialVersionUID = -559462759L; 077 078 /* 079 * Constructor 080 */ 081 public Resource() { 082 super(); 083 } 084 085 /** 086 * @return {@link #id} (The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value 087 */ 088 public IdType getIdElement() { 089 if (this.id == null) 090 if (Configuration.errorOnAutoCreate()) 091 throw new Error("Attempt to auto-create Resource.id"); 092 else if (Configuration.doAutoCreate()) 093 this.id = new IdType(); // bb 094 return this.id; 095 } 096 097 public boolean hasIdElement() { 098 return this.id != null && !this.id.isEmpty(); 099 } 100 101 public boolean hasId() { 102 return this.id != null && !this.id.isEmpty(); 103 } 104 105 /** 106 * @param value {@link #id} (The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value 107 */ 108 public Resource setIdElement(IdType value) { 109 this.id = value; 110 return this; 111 } 112 113 /** 114 * @return The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. 115 */ 116 public String getId() { 117 return this.id == null ? null : this.id.getValue(); 118 } 119 120 /** 121 * @param value The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. 122 */ 123 public Resource setId(String value) { 124 if (Utilities.noString(value)) 125 this.id = null; 126 else { 127 if (this.id == null) 128 this.id = new IdType(); 129 this.id.setValue(value); 130 } 131 return this; 132 } 133 134 /** 135 * @return {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.) 136 */ 137 public Meta getMeta() { 138 if (this.meta == null) 139 if (Configuration.errorOnAutoCreate()) 140 throw new Error("Attempt to auto-create Resource.meta"); 141 else if (Configuration.doAutoCreate()) 142 this.meta = new Meta(); // cc 143 return this.meta; 144 } 145 146 public boolean hasMeta() { 147 return this.meta != null && !this.meta.isEmpty(); 148 } 149 150 /** 151 * @param value {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.) 152 */ 153 public Resource setMeta(Meta value) { 154 this.meta = value; 155 return this; 156 } 157 158 /** 159 * @return {@link #implicitRules} (A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value 160 */ 161 public UriType getImplicitRulesElement() { 162 if (this.implicitRules == null) 163 if (Configuration.errorOnAutoCreate()) 164 throw new Error("Attempt to auto-create Resource.implicitRules"); 165 else if (Configuration.doAutoCreate()) 166 this.implicitRules = new UriType(); // bb 167 return this.implicitRules; 168 } 169 170 public boolean hasImplicitRulesElement() { 171 return this.implicitRules != null && !this.implicitRules.isEmpty(); 172 } 173 174 public boolean hasImplicitRules() { 175 return this.implicitRules != null && !this.implicitRules.isEmpty(); 176 } 177 178 /** 179 * @param value {@link #implicitRules} (A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value 180 */ 181 public Resource setImplicitRulesElement(UriType value) { 182 this.implicitRules = value; 183 return this; 184 } 185 186 /** 187 * @return A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. 188 */ 189 public String getImplicitRules() { 190 return this.implicitRules == null ? null : this.implicitRules.getValue(); 191 } 192 193 /** 194 * @param value A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. 195 */ 196 public Resource setImplicitRules(String value) { 197 if (Utilities.noString(value)) 198 this.implicitRules = null; 199 else { 200 if (this.implicitRules == null) 201 this.implicitRules = new UriType(); 202 this.implicitRules.setValue(value); 203 } 204 return this; 205 } 206 207 /** 208 * @return {@link #language} (The base language in which the resource is written.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value 209 */ 210 public CodeType getLanguageElement() { 211 if (this.language == null) 212 if (Configuration.errorOnAutoCreate()) 213 throw new Error("Attempt to auto-create Resource.language"); 214 else if (Configuration.doAutoCreate()) 215 this.language = new CodeType(); // bb 216 return this.language; 217 } 218 219 public boolean hasLanguageElement() { 220 return this.language != null && !this.language.isEmpty(); 221 } 222 223 public boolean hasLanguage() { 224 return this.language != null && !this.language.isEmpty(); 225 } 226 227 /** 228 * @param value {@link #language} (The base language in which the resource is written.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value 229 */ 230 public Resource setLanguageElement(CodeType value) { 231 this.language = value; 232 return this; 233 } 234 235 /** 236 * @return The base language in which the resource is written. 237 */ 238 public String getLanguage() { 239 return this.language == null ? null : this.language.getValue(); 240 } 241 242 /** 243 * @param value The base language in which the resource is written. 244 */ 245 public Resource setLanguage(String value) { 246 if (Utilities.noString(value)) 247 this.language = null; 248 else { 249 if (this.language == null) 250 this.language = new CodeType(); 251 this.language.setValue(value); 252 } 253 return this; 254 } 255 256 protected void listChildren(List<Property> childrenList) { 257 childrenList.add(new Property("id", "id", "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.", 0, java.lang.Integer.MAX_VALUE, id)); 258 childrenList.add(new Property("meta", "Meta", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.", 0, java.lang.Integer.MAX_VALUE, meta)); 259 childrenList.add(new Property("implicitRules", "uri", "A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.", 0, java.lang.Integer.MAX_VALUE, implicitRules)); 260 childrenList.add(new Property("language", "code", "The base language in which the resource is written.", 0, java.lang.Integer.MAX_VALUE, language)); 261 } 262 263 @Override 264 public void setProperty(String name, Base value) throws FHIRException { 265 if (name.equals("id")) 266 this.id = castToId(value); // IdType 267 else if (name.equals("meta")) 268 this.meta = castToMeta(value); // Meta 269 else if (name.equals("implicitRules")) 270 this.implicitRules = castToUri(value); // UriType 271 else if (name.equals("language")) 272 this.language = castToCode(value); // CodeType 273 else 274 super.setProperty(name, value); 275 } 276 277 @Override 278 public Base addChild(String name) throws FHIRException { 279 if (name.equals("id")) { 280 throw new FHIRException("Cannot call addChild on a primitive type Resource.id"); 281 } 282 else if (name.equals("meta")) { 283 this.meta = new Meta(); 284 return this.meta; 285 } 286 else if (name.equals("implicitRules")) { 287 throw new FHIRException("Cannot call addChild on a primitive type Resource.implicitRules"); 288 } 289 else if (name.equals("language")) { 290 throw new FHIRException("Cannot call addChild on a primitive type Resource.language"); 291 } 292 else 293 return super.addChild(name); 294 } 295 296 public String fhirType() { 297 return "Resource"; 298 299 } 300 301 public abstract Resource copy(); 302 303 public void copyValues(Resource dst) { 304 dst.id = id == null ? null : id.copy(); 305 dst.meta = meta == null ? null : meta.copy(); 306 dst.implicitRules = implicitRules == null ? null : implicitRules.copy(); 307 dst.language = language == null ? null : language.copy(); 308 } 309 310 @Override 311 public boolean equalsDeep(Base other) { 312 if (!super.equalsDeep(other)) 313 return false; 314 if (!(other instanceof Resource)) 315 return false; 316 Resource o = (Resource) other; 317 return compareDeep(id, o.id, true) && compareDeep(meta, o.meta, true) && compareDeep(implicitRules, o.implicitRules, true) 318 && compareDeep(language, o.language, true); 319 } 320 321 @Override 322 public boolean equalsShallow(Base other) { 323 if (!super.equalsShallow(other)) 324 return false; 325 if (!(other instanceof Resource)) 326 return false; 327 Resource o = (Resource) other; 328 return compareValues(id, o.id, true) && compareValues(implicitRules, o.implicitRules, true) && compareValues(language, o.language, true) 329 ; 330 } 331 332 public boolean isEmpty() { 333 return super.isEmpty() && (id == null || id.isEmpty()) && (meta == null || meta.isEmpty()) && (implicitRules == null || implicitRules.isEmpty()) 334 && (language == null || language.isEmpty()); 335 } 336 337 public abstract ResourceType getResourceType(); 338 339}