001package org.hl7.fhir.r4.model; 002 003 004 005/* 006 Copyright (c) 2011+, HL7, Inc. 007 All rights reserved. 008 009 Redistribution and use in source and binary forms, with or without modification, 010 are permitted provided that the following conditions are met: 011 012 * Redistributions of source code must retain the above copyright notice, this 013 list of conditions and the following disclaimer. 014 * Redistributions in binary form must reproduce the above copyright notice, 015 this list of conditions and the following disclaimer in the documentation 016 and/or other materials provided with the distribution. 017 * Neither the name of HL7 nor the names of its contributors may be used to 018 endorse or promote products derived from this software without specific 019 prior written permission. 020 021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 024 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 025 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 026 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 027 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 028 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 029 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 030 POSSIBILITY OF SUCH DAMAGE. 031 032*/ 033 034 035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1 036 037import java.util.*; 038 039import org.hl7.fhir.utilities.Utilities; 040import org.hl7.fhir.r4.model.Enumerations.*; 041import ca.uhn.fhir.model.api.annotation.ResourceDef; 042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 043import ca.uhn.fhir.model.api.annotation.Child; 044import ca.uhn.fhir.model.api.annotation.ChildOrder; 045import ca.uhn.fhir.model.api.annotation.Description; 046import ca.uhn.fhir.model.api.annotation.Block; 047import org.hl7.fhir.instance.model.api.*; 048import org.hl7.fhir.exceptions.FHIRException; 049/** 050 * This is the base resource type for everything. 051 */ 052public abstract class Resource extends BaseResource implements IAnyResource { 053 054 /** 055 * The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. 056 */ 057 @Child(name = "id", type = {IdType.class}, order=0, min=0, max=1, modifier=false, summary=true) 058 @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." ) 059 protected IdType id; 060 061 /** 062 * 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 */ 064 @Child(name = "meta", type = {Meta.class}, order=1, min=0, max=1, modifier=false, summary=true) 065 @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." ) 066 protected Meta meta; 067 068 /** 069 * 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 */ 071 @Child(name = "implicitRules", type = {UriType.class}, order=2, min=0, max=1, modifier=true, summary=true) 072 @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." ) 073 protected UriType implicitRules; 074 075 /** 076 * The base language in which the resource is written. 077 */ 078 @Child(name = "language", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=false) 079 @Description(shortDefinition="Language of the resource content", formalDefinition="The base language in which the resource is written." ) 080 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/languages") 081 protected CodeType language; 082 083 private static final long serialVersionUID = -559462759L; 084 085 /** 086 * Constructor 087 */ 088 public Resource() { 089 super(); 090 } 091 092 /** 093 * @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 094 */ 095 public IdType getIdElement() { 096 if (this.id == null) 097 if (Configuration.errorOnAutoCreate()) 098 throw new Error("Attempt to auto-create Resource.id"); 099 else if (Configuration.doAutoCreate()) 100 this.id = new IdType(); // bb 101 return this.id; 102 } 103 104 public boolean hasIdElement() { 105 return this.id != null && !this.id.isEmpty(); 106 } 107 108 public boolean hasId() { 109 return this.id != null && !this.id.isEmpty(); 110 } 111 112 /** 113 * @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 114 */ 115 public Resource setIdElement(IdType value) { 116 this.id = value; 117 return this; 118 } 119 120 /** 121 * @return The most complete id value of the resource, containing all 122 * available context and history. Once assigned this value never changes. 123 * NOTE: this value is NOT limited to just the logical id property of a 124 * resource id. 125 * @see IdType 126 * @see IdType#getValue() 127 */ 128 public String getId() { 129 return this.id == null ? null : this.id.getValue(); 130 } 131 132 /** 133 * @param value The id value of the resource. Once assigned, this value 134 * never changes. 135 * 136 * @see IdType 137 * @see IdType#setValue(String) 138 */ 139 public Resource setId(String value) { 140 if (Utilities.noString(value)) 141 this.id = null; 142 else { 143 if (this.id == null) 144 this.id = new IdType(); 145 this.id.setValue(value); 146 } 147 return this; 148 } 149 150 /** 151 * @return the logical ID part of this resource's id 152 * @see IdType#getIdPart() 153 */ 154 public String getIdPart() { 155 return getIdElement().getIdPart(); 156 } 157 158 /** 159 * @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.) 160 */ 161 public Meta getMeta() { 162 if (this.meta == null) 163 if (Configuration.errorOnAutoCreate()) 164 throw new Error("Attempt to auto-create Resource.meta"); 165 else if (Configuration.doAutoCreate()) 166 this.meta = new Meta(); // cc 167 return this.meta; 168 } 169 170 public boolean hasMeta() { 171 return this.meta != null && !this.meta.isEmpty(); 172 } 173 174 /** 175 * @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.) 176 */ 177 public Resource setMeta(Meta value) { 178 this.meta = value; 179 return this; 180 } 181 182 /** 183 * @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 184 */ 185 public UriType getImplicitRulesElement() { 186 if (this.implicitRules == null) 187 if (Configuration.errorOnAutoCreate()) 188 throw new Error("Attempt to auto-create Resource.implicitRules"); 189 else if (Configuration.doAutoCreate()) 190 this.implicitRules = new UriType(); // bb 191 return this.implicitRules; 192 } 193 194 public boolean hasImplicitRulesElement() { 195 return this.implicitRules != null && !this.implicitRules.isEmpty(); 196 } 197 198 public boolean hasImplicitRules() { 199 return this.implicitRules != null && !this.implicitRules.isEmpty(); 200 } 201 202 /** 203 * @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 204 */ 205 public Resource setImplicitRulesElement(UriType value) { 206 this.implicitRules = value; 207 return this; 208 } 209 210 /** 211 * @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. 212 */ 213 public String getImplicitRules() { 214 return this.implicitRules == null ? null : this.implicitRules.getValue(); 215 } 216 217 /** 218 * @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. 219 */ 220 public Resource setImplicitRules(String value) { 221 if (Utilities.noString(value)) 222 this.implicitRules = null; 223 else { 224 if (this.implicitRules == null) 225 this.implicitRules = new UriType(); 226 this.implicitRules.setValue(value); 227 } 228 return this; 229 } 230 231 /** 232 * @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 233 */ 234 public CodeType getLanguageElement() { 235 if (this.language == null) 236 if (Configuration.errorOnAutoCreate()) 237 throw new Error("Attempt to auto-create Resource.language"); 238 else if (Configuration.doAutoCreate()) 239 this.language = new CodeType(); // bb 240 return this.language; 241 } 242 243 public boolean hasLanguageElement() { 244 return this.language != null && !this.language.isEmpty(); 245 } 246 247 public boolean hasLanguage() { 248 return this.language != null && !this.language.isEmpty(); 249 } 250 251 /** 252 * @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 253 */ 254 public Resource setLanguageElement(CodeType value) { 255 this.language = value; 256 return this; 257 } 258 259 /** 260 * @return The base language in which the resource is written. 261 */ 262 public String getLanguage() { 263 return this.language == null ? null : this.language.getValue(); 264 } 265 266 /** 267 * @param value The base language in which the resource is written. 268 */ 269 public Resource setLanguage(String value) { 270 if (Utilities.noString(value)) 271 this.language = null; 272 else { 273 if (this.language == null) 274 this.language = new CodeType(); 275 this.language.setValue(value); 276 } 277 return this; 278 } 279 280 protected void listChildren(List<Property> children) { 281 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)); 282 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)); 283 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)); 284 children.add(new Property("language", "code", "The base language in which the resource is written.", 0, 1, language)); 285 } 286 287 @Override 288 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 289 switch (_hash) { 290 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); 291 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); 292 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); 293 case -1613589672: /*language*/ return new Property("language", "code", "The base language in which the resource is written.", 0, 1, language); 294 default: return super.getNamedProperty(_hash, _name, _checkValid); 295 } 296 297 } 298 299 @Override 300 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 301 switch (hash) { 302 case 3355: /*id*/ return this.id == null ? new Base[0] : new Base[] {this.id}; // IdType 303 case 3347973: /*meta*/ return this.meta == null ? new Base[0] : new Base[] {this.meta}; // Meta 304 case -961826286: /*implicitRules*/ return this.implicitRules == null ? new Base[0] : new Base[] {this.implicitRules}; // UriType 305 case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType 306 default: return super.getProperty(hash, name, checkValid); 307 } 308 309 } 310 311 @Override 312 public Base setProperty(int hash, String name, Base value) throws FHIRException { 313 switch (hash) { 314 case 3355: // id 315 this.id = castToId(value); // IdType 316 return value; 317 case 3347973: // meta 318 this.meta = castToMeta(value); // Meta 319 return value; 320 case -961826286: // implicitRules 321 this.implicitRules = castToUri(value); // UriType 322 return value; 323 case -1613589672: // language 324 this.language = castToCode(value); // CodeType 325 return value; 326 default: return super.setProperty(hash, name, value); 327 } 328 329 } 330 331 @Override 332 public Base setProperty(String name, Base value) throws FHIRException { 333 if (name.equals("id")) { 334 this.id = castToId(value); // IdType 335 } else if (name.equals("meta")) { 336 this.meta = castToMeta(value); // Meta 337 } else if (name.equals("implicitRules")) { 338 this.implicitRules = castToUri(value); // UriType 339 } else if (name.equals("language")) { 340 this.language = castToCode(value); // CodeType 341 } else 342 return super.setProperty(name, value); 343 return value; 344 } 345 346 @Override 347 public Base makeProperty(int hash, String name) throws FHIRException { 348 switch (hash) { 349 case 3355: return getIdElement(); 350 case 3347973: return getMeta(); 351 case -961826286: return getImplicitRulesElement(); 352 case -1613589672: return getLanguageElement(); 353 default: return super.makeProperty(hash, name); 354 } 355 356 } 357 358 @Override 359 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 360 switch (hash) { 361 case 3355: /*id*/ return new String[] {"id"}; 362 case 3347973: /*meta*/ return new String[] {"Meta"}; 363 case -961826286: /*implicitRules*/ return new String[] {"uri"}; 364 case -1613589672: /*language*/ return new String[] {"code"}; 365 default: return super.getTypesForProperty(hash, name); 366 } 367 368 } 369 370 @Override 371 public Base addChild(String name) throws FHIRException { 372 if (name.equals("id")) { 373 throw new FHIRException("Cannot call addChild on a primitive type Resource.id"); 374 } 375 else if (name.equals("meta")) { 376 this.meta = new Meta(); 377 return this.meta; 378 } 379 else if (name.equals("implicitRules")) { 380 throw new FHIRException("Cannot call addChild on a primitive type Resource.implicitRules"); 381 } 382 else if (name.equals("language")) { 383 throw new FHIRException("Cannot call addChild on a primitive type Resource.language"); 384 } 385 else 386 return super.addChild(name); 387 } 388 389 public String fhirType() { 390 return "Resource"; 391 392 } 393 394 public abstract Resource copy(); 395 396 public void copyValues(Resource dst) { 397 dst.id = id == null ? null : id.copy(); 398 dst.meta = meta == null ? null : meta.copy(); 399 dst.implicitRules = implicitRules == null ? null : implicitRules.copy(); 400 dst.language = language == null ? null : language.copy(); 401 } 402 403 @Override 404 public boolean equalsDeep(Base other_) { 405 if (!super.equalsDeep(other_)) 406 return false; 407 if (!(other_ instanceof Resource)) 408 return false; 409 Resource o = (Resource) other_; 410 return compareDeep(id, o.id, true) && compareDeep(meta, o.meta, true) && compareDeep(implicitRules, o.implicitRules, true) 411 && compareDeep(language, o.language, true); 412 } 413 414 @Override 415 public boolean equalsShallow(Base other_) { 416 if (!super.equalsShallow(other_)) 417 return false; 418 if (!(other_ instanceof Resource)) 419 return false; 420 Resource o = (Resource) other_; 421 return compareValues(id, o.id, true) && compareValues(implicitRules, o.implicitRules, true) && compareValues(language, o.language, true) 422 ; 423 } 424 425 public boolean isEmpty() { 426 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(id, meta, implicitRules 427 , language); 428 } 429 430 431 @Override 432 public String getIdBase() { 433 return getId(); 434 } 435 436 @Override 437 public void setIdBase(String value) { 438 setId(value); 439 } 440 public abstract ResourceType getResourceType(); 441// added from java-adornments.txt: 442 443 public String getLanguage(String defValue) { 444 return hasLanguage() ? getLanguage() : defValue; 445 } 446 447 448// end addition 449 450}