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 org.hl7.fhir.utilities.Utilities; 037import org.hl7.fhir.r4.model.Enumerations.*; 038import ca.uhn.fhir.model.api.annotation.ResourceDef; 039import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 040import ca.uhn.fhir.model.api.annotation.Child; 041import ca.uhn.fhir.model.api.annotation.ChildOrder; 042import ca.uhn.fhir.model.api.annotation.Description; 043import ca.uhn.fhir.model.api.annotation.Block; 044import org.hl7.fhir.instance.model.api.*; 045import org.hl7.fhir.exceptions.FHIRException; 046/** 047 * This is the base resource type for everything. 048 */ 049public abstract class Resource extends BaseResource implements IAnyResource { 050 051 /** 052 * The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. 053 */ 054 @Child(name = "id", type = {IdType.class}, order=0, min=0, max=1, modifier=false, summary=true) 055 @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." ) 056 protected IdType id; 057 058 /** 059 * The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource. 060 */ 061 @Child(name = "meta", type = {Meta.class}, order=1, min=0, max=1, modifier=false, summary=true) 062 @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 might not always be associated with version changes to the resource." ) 063 protected Meta meta; 064 065 /** 066 * A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc. 067 */ 068 @Child(name = "implicitRules", type = {UriType.class}, order=2, min=0, max=1, modifier=true, summary=true) 069 @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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc." ) 070 protected UriType implicitRules; 071 072 /** 073 * The base language in which the resource is written. 074 */ 075 @Child(name = "language", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=false) 076 @Description(shortDefinition="Language of the resource content", formalDefinition="The base language in which the resource is written." ) 077 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/languages") 078 protected CodeType language; 079 080 private static final long serialVersionUID = -559462759L; 081 082 /** 083 * Constructor 084 */ 085 public Resource() { 086 super(); 087 } 088 089 /** 090 * @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 091 */ 092 public IdType getIdElement() { 093 if (this.id == null) 094 if (Configuration.errorOnAutoCreate()) 095 throw new Error("Attempt to auto-create Resource.id"); 096 else if (Configuration.doAutoCreate()) 097 this.id = new IdType(); // bb 098 return this.id; 099 } 100 101 public boolean hasIdElement() { 102 return this.id != null && !this.id.isEmpty(); 103 } 104 105 public boolean hasId() { 106 return this.id != null && !this.id.isEmpty(); 107 } 108 109 /** 110 * @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 111 */ 112 public Resource setIdElement(IdType value) { 113 this.id = value; 114 return this; 115 } 116 117 /** 118 * @return The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. 119 */ 120 public String getId() { 121 return this.id == null ? null : this.id.getValue(); 122 } 123 124 /** 125 * @param value The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. 126 */ 127 public Resource setId(String value) { 128 if (Utilities.noString(value)) 129 this.id = null; 130 else { 131 if (this.id == null) 132 this.id = new IdType(); 133 this.id.setValue(value); 134 } 135 return this; 136 } 137 138 /** 139 * @return {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.) 140 */ 141 public Meta getMeta() { 142 if (this.meta == null) 143 if (Configuration.errorOnAutoCreate()) 144 throw new Error("Attempt to auto-create Resource.meta"); 145 else if (Configuration.doAutoCreate()) 146 this.meta = new Meta(); // cc 147 return this.meta; 148 } 149 150 public boolean hasMeta() { 151 return this.meta != null && !this.meta.isEmpty(); 152 } 153 154 /** 155 * @param value {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.) 156 */ 157 public Resource setMeta(Meta value) { 158 this.meta = value; 159 return this; 160 } 161 162 /** 163 * @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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value 164 */ 165 public UriType getImplicitRulesElement() { 166 if (this.implicitRules == null) 167 if (Configuration.errorOnAutoCreate()) 168 throw new Error("Attempt to auto-create Resource.implicitRules"); 169 else if (Configuration.doAutoCreate()) 170 this.implicitRules = new UriType(); // bb 171 return this.implicitRules; 172 } 173 174 public boolean hasImplicitRulesElement() { 175 return this.implicitRules != null && !this.implicitRules.isEmpty(); 176 } 177 178 public boolean hasImplicitRules() { 179 return this.implicitRules != null && !this.implicitRules.isEmpty(); 180 } 181 182 /** 183 * @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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value 184 */ 185 public Resource setImplicitRulesElement(UriType value) { 186 this.implicitRules = value; 187 return this; 188 } 189 190 /** 191 * @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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc. 192 */ 193 public String getImplicitRules() { 194 return this.implicitRules == null ? null : this.implicitRules.getValue(); 195 } 196 197 /** 198 * @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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc. 199 */ 200 public Resource setImplicitRules(String value) { 201 if (Utilities.noString(value)) 202 this.implicitRules = null; 203 else { 204 if (this.implicitRules == null) 205 this.implicitRules = new UriType(); 206 this.implicitRules.setValue(value); 207 } 208 return this; 209 } 210 211 /** 212 * @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 213 */ 214 public CodeType getLanguageElement() { 215 if (this.language == null) 216 if (Configuration.errorOnAutoCreate()) 217 throw new Error("Attempt to auto-create Resource.language"); 218 else if (Configuration.doAutoCreate()) 219 this.language = new CodeType(); // bb 220 return this.language; 221 } 222 223 public boolean hasLanguageElement() { 224 return this.language != null && !this.language.isEmpty(); 225 } 226 227 public boolean hasLanguage() { 228 return this.language != null && !this.language.isEmpty(); 229 } 230 231 /** 232 * @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 233 */ 234 public Resource setLanguageElement(CodeType value) { 235 this.language = value; 236 return this; 237 } 238 239 /** 240 * @return The base language in which the resource is written. 241 */ 242 public String getLanguage() { 243 return this.language == null ? null : this.language.getValue(); 244 } 245 246 /** 247 * @param value The base language in which the resource is written. 248 */ 249 public Resource setLanguage(String value) { 250 if (Utilities.noString(value)) 251 this.language = null; 252 else { 253 if (this.language == null) 254 this.language = new CodeType(); 255 this.language.setValue(value); 256 } 257 return this; 258 } 259 260 protected void listChildren(List<Property> children) { 261 children.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, 1, id)); 262 children.add(new Property("meta", "Meta", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.", 0, 1, meta)); 263 children.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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", 0, 1, implicitRules)); 264 children.add(new Property("language", "code", "The base language in which the resource is written.", 0, 1, language)); 265 } 266 267 @Override 268 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 269 switch (_hash) { 270 case 3355: /*id*/ return 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, 1, id); 271 case 3347973: /*meta*/ return new Property("meta", "Meta", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.", 0, 1, meta); 272 case -961826286: /*implicitRules*/ return 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. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", 0, 1, implicitRules); 273 case -1613589672: /*language*/ return new Property("language", "code", "The base language in which the resource is written.", 0, 1, language); 274 default: return super.getNamedProperty(_hash, _name, _checkValid); 275 } 276 277 } 278 279 @Override 280 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 281 switch (hash) { 282 case 3355: /*id*/ return this.id == null ? new Base[0] : new Base[] {this.id}; // IdType 283 case 3347973: /*meta*/ return this.meta == null ? new Base[0] : new Base[] {this.meta}; // Meta 284 case -961826286: /*implicitRules*/ return this.implicitRules == null ? new Base[0] : new Base[] {this.implicitRules}; // UriType 285 case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType 286 default: return super.getProperty(hash, name, checkValid); 287 } 288 289 } 290 291 @Override 292 public Base setProperty(int hash, String name, Base value) throws FHIRException { 293 switch (hash) { 294 case 3355: // id 295 this.id = castToId(value); // IdType 296 return value; 297 case 3347973: // meta 298 this.meta = castToMeta(value); // Meta 299 return value; 300 case -961826286: // implicitRules 301 this.implicitRules = castToUri(value); // UriType 302 return value; 303 case -1613589672: // language 304 this.language = castToCode(value); // CodeType 305 return value; 306 default: return super.setProperty(hash, name, value); 307 } 308 309 } 310 311 @Override 312 public Base setProperty(String name, Base value) throws FHIRException { 313 if (name.equals("id")) { 314 this.id = castToId(value); // IdType 315 } else if (name.equals("meta")) { 316 this.meta = castToMeta(value); // Meta 317 } else if (name.equals("implicitRules")) { 318 this.implicitRules = castToUri(value); // UriType 319 } else if (name.equals("language")) { 320 this.language = castToCode(value); // CodeType 321 } else 322 return super.setProperty(name, value); 323 return value; 324 } 325 326 @Override 327 public Base makeProperty(int hash, String name) throws FHIRException { 328 switch (hash) { 329 case 3355: return getIdElement(); 330 case 3347973: return getMeta(); 331 case -961826286: return getImplicitRulesElement(); 332 case -1613589672: return getLanguageElement(); 333 default: return super.makeProperty(hash, name); 334 } 335 336 } 337 338 @Override 339 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 340 switch (hash) { 341 case 3355: /*id*/ return new String[] {"id"}; 342 case 3347973: /*meta*/ return new String[] {"Meta"}; 343 case -961826286: /*implicitRules*/ return new String[] {"uri"}; 344 case -1613589672: /*language*/ return new String[] {"code"}; 345 default: return super.getTypesForProperty(hash, name); 346 } 347 348 } 349 350 @Override 351 public Base addChild(String name) throws FHIRException { 352 if (name.equals("id")) { 353 throw new FHIRException("Cannot call addChild on a primitive type Resource.id"); 354 } 355 else if (name.equals("meta")) { 356 this.meta = new Meta(); 357 return this.meta; 358 } 359 else if (name.equals("implicitRules")) { 360 throw new FHIRException("Cannot call addChild on a primitive type Resource.implicitRules"); 361 } 362 else if (name.equals("language")) { 363 throw new FHIRException("Cannot call addChild on a primitive type Resource.language"); 364 } 365 else 366 return super.addChild(name); 367 } 368 369 public String fhirType() { 370 return "Resource"; 371 372 } 373 374 public abstract Resource copy(); 375 376 public void copyValues(Resource dst) { 377 dst.id = id == null ? null : id.copy(); 378 dst.meta = meta == null ? null : meta.copy(); 379 dst.implicitRules = implicitRules == null ? null : implicitRules.copy(); 380 dst.language = language == null ? null : language.copy(); 381 } 382 383 @Override 384 public boolean equalsDeep(Base other_) { 385 if (!super.equalsDeep(other_)) 386 return false; 387 if (!(other_ instanceof Resource)) 388 return false; 389 Resource o = (Resource) other_; 390 return compareDeep(id, o.id, true) && compareDeep(meta, o.meta, true) && compareDeep(implicitRules, o.implicitRules, true) 391 && compareDeep(language, o.language, true); 392 } 393 394 @Override 395 public boolean equalsShallow(Base other_) { 396 if (!super.equalsShallow(other_)) 397 return false; 398 if (!(other_ instanceof Resource)) 399 return false; 400 Resource o = (Resource) other_; 401 return compareValues(id, o.id, true) && compareValues(implicitRules, o.implicitRules, true) && compareValues(language, o.language, true) 402 ; 403 } 404 405 public boolean isEmpty() { 406 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(id, meta, implicitRules 407 , language); 408 } 409 410 411 @Override 412 public String getIdBase() { 413 return getId(); 414 } 415 416 @Override 417 public void setIdBase(String value) { 418 setId(value); 419 } 420 public abstract ResourceType getResourceType(); 421// added from java-adornments.txt: 422 423 public String getLanguage(String defValue) { 424 return hasLanguage() ? getLanguage() : defValue; 425 } 426 427 428// end addition 429 430} 431