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