001package org.hl7.fhir.r5.model; 002 003 004/* 005 Copyright (c) 2011+, HL7, Inc. 006 All rights reserved. 007 008 Redistribution and use in source and binary forms, with or without modification, \ 009 are permitted provided that the following conditions are met: 010 011 * Redistributions of source code must retain the above copyright notice, this \ 012 list of conditions and the following disclaimer. 013 * Redistributions in binary form must reproduce the above copyright notice, \ 014 this list of conditions and the following disclaimer in the documentation \ 015 and/or other materials provided with the distribution. 016 * Neither the name of HL7 nor the names of its contributors may be used to 017 endorse or promote products derived from this software without specific 018 prior written permission. 019 020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \ 021 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \ 022 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \ 023 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \ 024 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \ 025 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \ 026 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \ 027 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \ 028 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \ 029 POSSIBILITY OF SUCH DAMAGE. 030 */ 031 032// Generated on Tue, Dec 28, 2021 07:16+1100 for FHIR v5.0.0-snapshot1 033 034import java.util.ArrayList; 035import java.util.Date; 036import java.util.List; 037import org.hl7.fhir.utilities.Utilities; 038import org.hl7.fhir.r5.model.Enumerations.*; 039import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; 040import org.hl7.fhir.exceptions.FHIRException; 041import org.hl7.fhir.instance.model.api.ICompositeType; 042import ca.uhn.fhir.model.api.annotation.Child; 043import ca.uhn.fhir.model.api.annotation.ChildOrder; 044import ca.uhn.fhir.model.api.annotation.DatatypeDef; 045import ca.uhn.fhir.model.api.annotation.Description; 046import ca.uhn.fhir.model.api.annotation.Block; 047 048/** 049 * Base StructureDefinition for Expression Type: A expression that is evaluated in a specified context and returns a value. The context of use of the expression must specify the context in which the expression is evaluated, and how the result of the expression is used. 050 */ 051@DatatypeDef(name="Expression") 052public class Expression extends DataType implements ICompositeType { 053 054 /** 055 * A brief, natural language description of the condition that effectively communicates the intended semantics. 056 */ 057 @Child(name = "description", type = {StringType.class}, order=0, min=0, max=1, modifier=false, summary=true) 058 @Description(shortDefinition="Natural language description of the condition", formalDefinition="A brief, natural language description of the condition that effectively communicates the intended semantics." ) 059 protected StringType description; 060 061 /** 062 * A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined. 063 */ 064 @Child(name = "name", type = {IdType.class}, order=1, min=0, max=1, modifier=false, summary=true) 065 @Description(shortDefinition="Short name assigned to expression for reuse", formalDefinition="A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined." ) 066 protected IdType name; 067 068 /** 069 * The media type of the language for the expression. 070 */ 071 @Child(name = "language", type = {CodeType.class}, order=2, min=1, max=1, modifier=false, summary=true) 072 @Description(shortDefinition="text/cql | text/fhirpath | application/x-fhir-query | etc.", formalDefinition="The media type of the language for the expression." ) 073 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/expression-language") 074 protected CodeType language; 075 076 /** 077 * An expression in the specified language that returns a value. 078 */ 079 @Child(name = "expression", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true) 080 @Description(shortDefinition="Expression in specified language", formalDefinition="An expression in the specified language that returns a value." ) 081 protected StringType expression; 082 083 /** 084 * A URI that defines where the expression is found. 085 */ 086 @Child(name = "reference", type = {UriType.class}, order=4, min=0, max=1, modifier=false, summary=true) 087 @Description(shortDefinition="Where the expression is found", formalDefinition="A URI that defines where the expression is found." ) 088 protected UriType reference; 089 090 private static final long serialVersionUID = -465056222L; 091 092 /** 093 * Constructor 094 */ 095 public Expression() { 096 super(); 097 } 098 099 /** 100 * Constructor 101 */ 102 public Expression(String language) { 103 super(); 104 this.setLanguage(language); 105 } 106 107 /** 108 * @return {@link #description} (A brief, natural language description of the condition that effectively communicates the intended semantics.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value 109 */ 110 public StringType getDescriptionElement() { 111 if (this.description == null) 112 if (Configuration.errorOnAutoCreate()) 113 throw new Error("Attempt to auto-create Expression.description"); 114 else if (Configuration.doAutoCreate()) 115 this.description = new StringType(); // bb 116 return this.description; 117 } 118 119 public boolean hasDescriptionElement() { 120 return this.description != null && !this.description.isEmpty(); 121 } 122 123 public boolean hasDescription() { 124 return this.description != null && !this.description.isEmpty(); 125 } 126 127 /** 128 * @param value {@link #description} (A brief, natural language description of the condition that effectively communicates the intended semantics.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value 129 */ 130 public Expression setDescriptionElement(StringType value) { 131 this.description = value; 132 return this; 133 } 134 135 /** 136 * @return A brief, natural language description of the condition that effectively communicates the intended semantics. 137 */ 138 public String getDescription() { 139 return this.description == null ? null : this.description.getValue(); 140 } 141 142 /** 143 * @param value A brief, natural language description of the condition that effectively communicates the intended semantics. 144 */ 145 public Expression setDescription(String value) { 146 if (Utilities.noString(value)) 147 this.description = null; 148 else { 149 if (this.description == null) 150 this.description = new StringType(); 151 this.description.setValue(value); 152 } 153 return this; 154 } 155 156 /** 157 * @return {@link #name} (A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value 158 */ 159 public IdType getNameElement() { 160 if (this.name == null) 161 if (Configuration.errorOnAutoCreate()) 162 throw new Error("Attempt to auto-create Expression.name"); 163 else if (Configuration.doAutoCreate()) 164 this.name = new IdType(); // bb 165 return this.name; 166 } 167 168 public boolean hasNameElement() { 169 return this.name != null && !this.name.isEmpty(); 170 } 171 172 public boolean hasName() { 173 return this.name != null && !this.name.isEmpty(); 174 } 175 176 /** 177 * @param value {@link #name} (A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value 178 */ 179 public Expression setNameElement(IdType value) { 180 this.name = value; 181 return this; 182 } 183 184 /** 185 * @return A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined. 186 */ 187 public String getName() { 188 return this.name == null ? null : this.name.getValue(); 189 } 190 191 /** 192 * @param value A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined. 193 */ 194 public Expression setName(String value) { 195 if (Utilities.noString(value)) 196 this.name = null; 197 else { 198 if (this.name == null) 199 this.name = new IdType(); 200 this.name.setValue(value); 201 } 202 return this; 203 } 204 205 /** 206 * @return {@link #language} (The media type of the language for the expression.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value 207 */ 208 public CodeType getLanguageElement() { 209 if (this.language == null) 210 if (Configuration.errorOnAutoCreate()) 211 throw new Error("Attempt to auto-create Expression.language"); 212 else if (Configuration.doAutoCreate()) 213 this.language = new CodeType(); // bb 214 return this.language; 215 } 216 217 public boolean hasLanguageElement() { 218 return this.language != null && !this.language.isEmpty(); 219 } 220 221 public boolean hasLanguage() { 222 return this.language != null && !this.language.isEmpty(); 223 } 224 225 /** 226 * @param value {@link #language} (The media type of the language for the expression.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value 227 */ 228 public Expression setLanguageElement(CodeType value) { 229 this.language = value; 230 return this; 231 } 232 233 /** 234 * @return The media type of the language for the expression. 235 */ 236 public String getLanguage() { 237 return this.language == null ? null : this.language.getValue(); 238 } 239 240 /** 241 * @param value The media type of the language for the expression. 242 */ 243 public Expression setLanguage(String value) { 244 if (this.language == null) 245 this.language = new CodeType(); 246 this.language.setValue(value); 247 return this; 248 } 249 250 /** 251 * @return {@link #expression} (An expression in the specified language that returns a value.). This is the underlying object with id, value and extensions. The accessor "getExpression" gives direct access to the value 252 */ 253 public StringType getExpressionElement() { 254 if (this.expression == null) 255 if (Configuration.errorOnAutoCreate()) 256 throw new Error("Attempt to auto-create Expression.expression"); 257 else if (Configuration.doAutoCreate()) 258 this.expression = new StringType(); // bb 259 return this.expression; 260 } 261 262 public boolean hasExpressionElement() { 263 return this.expression != null && !this.expression.isEmpty(); 264 } 265 266 public boolean hasExpression() { 267 return this.expression != null && !this.expression.isEmpty(); 268 } 269 270 /** 271 * @param value {@link #expression} (An expression in the specified language that returns a value.). This is the underlying object with id, value and extensions. The accessor "getExpression" gives direct access to the value 272 */ 273 public Expression setExpressionElement(StringType value) { 274 this.expression = value; 275 return this; 276 } 277 278 /** 279 * @return An expression in the specified language that returns a value. 280 */ 281 public String getExpression() { 282 return this.expression == null ? null : this.expression.getValue(); 283 } 284 285 /** 286 * @param value An expression in the specified language that returns a value. 287 */ 288 public Expression setExpression(String value) { 289 if (Utilities.noString(value)) 290 this.expression = null; 291 else { 292 if (this.expression == null) 293 this.expression = new StringType(); 294 this.expression.setValue(value); 295 } 296 return this; 297 } 298 299 /** 300 * @return {@link #reference} (A URI that defines where the expression is found.). This is the underlying object with id, value and extensions. The accessor "getReference" gives direct access to the value 301 */ 302 public UriType getReferenceElement() { 303 if (this.reference == null) 304 if (Configuration.errorOnAutoCreate()) 305 throw new Error("Attempt to auto-create Expression.reference"); 306 else if (Configuration.doAutoCreate()) 307 this.reference = new UriType(); // bb 308 return this.reference; 309 } 310 311 public boolean hasReferenceElement() { 312 return this.reference != null && !this.reference.isEmpty(); 313 } 314 315 public boolean hasReference() { 316 return this.reference != null && !this.reference.isEmpty(); 317 } 318 319 /** 320 * @param value {@link #reference} (A URI that defines where the expression is found.). This is the underlying object with id, value and extensions. The accessor "getReference" gives direct access to the value 321 */ 322 public Expression setReferenceElement(UriType value) { 323 this.reference = value; 324 return this; 325 } 326 327 /** 328 * @return A URI that defines where the expression is found. 329 */ 330 public String getReference() { 331 return this.reference == null ? null : this.reference.getValue(); 332 } 333 334 /** 335 * @param value A URI that defines where the expression is found. 336 */ 337 public Expression setReference(String value) { 338 if (Utilities.noString(value)) 339 this.reference = null; 340 else { 341 if (this.reference == null) 342 this.reference = new UriType(); 343 this.reference.setValue(value); 344 } 345 return this; 346 } 347 348 protected void listChildren(List<Property> children) { 349 super.listChildren(children); 350 children.add(new Property("description", "string", "A brief, natural language description of the condition that effectively communicates the intended semantics.", 0, 1, description)); 351 children.add(new Property("name", "id", "A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined.", 0, 1, name)); 352 children.add(new Property("language", "code", "The media type of the language for the expression.", 0, 1, language)); 353 children.add(new Property("expression", "string", "An expression in the specified language that returns a value.", 0, 1, expression)); 354 children.add(new Property("reference", "uri", "A URI that defines where the expression is found.", 0, 1, reference)); 355 } 356 357 @Override 358 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 359 switch (_hash) { 360 case -1724546052: /*description*/ return new Property("description", "string", "A brief, natural language description of the condition that effectively communicates the intended semantics.", 0, 1, description); 361 case 3373707: /*name*/ return new Property("name", "id", "A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined.", 0, 1, name); 362 case -1613589672: /*language*/ return new Property("language", "code", "The media type of the language for the expression.", 0, 1, language); 363 case -1795452264: /*expression*/ return new Property("expression", "string", "An expression in the specified language that returns a value.", 0, 1, expression); 364 case -925155509: /*reference*/ return new Property("reference", "uri", "A URI that defines where the expression is found.", 0, 1, reference); 365 default: return super.getNamedProperty(_hash, _name, _checkValid); 366 } 367 368 } 369 370 @Override 371 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 372 switch (hash) { 373 case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType 374 case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // IdType 375 case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType 376 case -1795452264: /*expression*/ return this.expression == null ? new Base[0] : new Base[] {this.expression}; // StringType 377 case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // UriType 378 default: return super.getProperty(hash, name, checkValid); 379 } 380 381 } 382 383 @Override 384 public Base setProperty(int hash, String name, Base value) throws FHIRException { 385 switch (hash) { 386 case -1724546052: // description 387 this.description = TypeConvertor.castToString(value); // StringType 388 return value; 389 case 3373707: // name 390 this.name = TypeConvertor.castToId(value); // IdType 391 return value; 392 case -1613589672: // language 393 this.language = TypeConvertor.castToCode(value); // CodeType 394 return value; 395 case -1795452264: // expression 396 this.expression = TypeConvertor.castToString(value); // StringType 397 return value; 398 case -925155509: // reference 399 this.reference = TypeConvertor.castToUri(value); // UriType 400 return value; 401 default: return super.setProperty(hash, name, value); 402 } 403 404 } 405 406 @Override 407 public Base setProperty(String name, Base value) throws FHIRException { 408 if (name.equals("description")) { 409 this.description = TypeConvertor.castToString(value); // StringType 410 } else if (name.equals("name")) { 411 this.name = TypeConvertor.castToId(value); // IdType 412 } else if (name.equals("language")) { 413 this.language = TypeConvertor.castToCode(value); // CodeType 414 } else if (name.equals("expression")) { 415 this.expression = TypeConvertor.castToString(value); // StringType 416 } else if (name.equals("reference")) { 417 this.reference = TypeConvertor.castToUri(value); // UriType 418 } else 419 return super.setProperty(name, value); 420 return value; 421 } 422 423 @Override 424 public Base makeProperty(int hash, String name) throws FHIRException { 425 switch (hash) { 426 case -1724546052: return getDescriptionElement(); 427 case 3373707: return getNameElement(); 428 case -1613589672: return getLanguageElement(); 429 case -1795452264: return getExpressionElement(); 430 case -925155509: return getReferenceElement(); 431 default: return super.makeProperty(hash, name); 432 } 433 434 } 435 436 @Override 437 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 438 switch (hash) { 439 case -1724546052: /*description*/ return new String[] {"string"}; 440 case 3373707: /*name*/ return new String[] {"id"}; 441 case -1613589672: /*language*/ return new String[] {"code"}; 442 case -1795452264: /*expression*/ return new String[] {"string"}; 443 case -925155509: /*reference*/ return new String[] {"uri"}; 444 default: return super.getTypesForProperty(hash, name); 445 } 446 447 } 448 449 @Override 450 public Base addChild(String name) throws FHIRException { 451 if (name.equals("description")) { 452 throw new FHIRException("Cannot call addChild on a primitive type Expression.description"); 453 } 454 else if (name.equals("name")) { 455 throw new FHIRException("Cannot call addChild on a primitive type Expression.name"); 456 } 457 else if (name.equals("language")) { 458 throw new FHIRException("Cannot call addChild on a primitive type Expression.language"); 459 } 460 else if (name.equals("expression")) { 461 throw new FHIRException("Cannot call addChild on a primitive type Expression.expression"); 462 } 463 else if (name.equals("reference")) { 464 throw new FHIRException("Cannot call addChild on a primitive type Expression.reference"); 465 } 466 else 467 return super.addChild(name); 468 } 469 470 public String fhirType() { 471 return "Expression"; 472 473 } 474 475 public Expression copy() { 476 Expression dst = new Expression(); 477 copyValues(dst); 478 return dst; 479 } 480 481 public void copyValues(Expression dst) { 482 super.copyValues(dst); 483 dst.description = description == null ? null : description.copy(); 484 dst.name = name == null ? null : name.copy(); 485 dst.language = language == null ? null : language.copy(); 486 dst.expression = expression == null ? null : expression.copy(); 487 dst.reference = reference == null ? null : reference.copy(); 488 } 489 490 protected Expression typedCopy() { 491 return copy(); 492 } 493 494 @Override 495 public boolean equalsDeep(Base other_) { 496 if (!super.equalsDeep(other_)) 497 return false; 498 if (!(other_ instanceof Expression)) 499 return false; 500 Expression o = (Expression) other_; 501 return compareDeep(description, o.description, true) && compareDeep(name, o.name, true) && compareDeep(language, o.language, true) 502 && compareDeep(expression, o.expression, true) && compareDeep(reference, o.reference, true); 503 } 504 505 @Override 506 public boolean equalsShallow(Base other_) { 507 if (!super.equalsShallow(other_)) 508 return false; 509 if (!(other_ instanceof Expression)) 510 return false; 511 Expression o = (Expression) other_; 512 return compareValues(description, o.description, true) && compareValues(name, o.name, true) && compareValues(language, o.language, true) 513 && compareValues(expression, o.expression, true) && compareValues(reference, o.reference, true); 514 } 515 516 public boolean isEmpty() { 517 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(description, name, language 518 , expression, reference); 519 } 520 521 522} 523