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