001package org.hl7.fhir.dstu2016may.model; 002 003 004 005 006/* 007 Copyright (c) 2011+, HL7, Inc. 008 All rights reserved. 009 010 Redistribution and use in source and binary forms, with or without modification, 011 are permitted provided that the following conditions are met: 012 013 * Redistributions of source code must retain the above copyright notice, this 014 list of conditions and the following disclaimer. 015 * Redistributions in binary form must reproduce the above copyright notice, 016 this list of conditions and the following disclaimer in the documentation 017 and/or other materials provided with the distribution. 018 * Neither the name of HL7 nor the names of its contributors may be used to 019 endorse or promote products derived from this software without specific 020 prior written permission. 021 022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 025 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 026 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 027 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 028 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 029 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 030 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 031 POSSIBILITY OF SUCH DAMAGE. 032 033*/ 034 035// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0 036import java.util.ArrayList; 037import java.util.Date; 038import java.util.List; 039 040import org.hl7.fhir.exceptions.FHIRException; 041import org.hl7.fhir.instance.model.api.IBaseMetaType; 042import org.hl7.fhir.utilities.Utilities; 043 044import ca.uhn.fhir.model.api.annotation.Child; 045import ca.uhn.fhir.model.api.annotation.DatatypeDef; 046import ca.uhn.fhir.model.api.annotation.Description; 047/** 048 * The metadata about a resource. This is content in the resource that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource. 049 */ 050@DatatypeDef(name="Meta") 051public class Meta extends Type implements IBaseMetaType { 052 053 /** 054 * The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted. 055 */ 056 @Child(name = "versionId", type = {IdType.class}, order=0, min=0, max=1, modifier=false, summary=true) 057 @Description(shortDefinition="Version specific identifier", formalDefinition="The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted." ) 058 protected IdType versionId; 059 060 /** 061 * When the resource last changed - e.g. when the version changed. 062 */ 063 @Child(name = "lastUpdated", type = {InstantType.class}, order=1, min=0, max=1, modifier=false, summary=true) 064 @Description(shortDefinition="When the resource version last changed", formalDefinition="When the resource last changed - e.g. when the version changed." ) 065 protected InstantType lastUpdated; 066 067 /** 068 * A list of profiles [[[StructureDefinition]]]s that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]]. 069 */ 070 @Child(name = "profile", type = {UriType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 071 @Description(shortDefinition="Profiles this resource claims to conform to", formalDefinition="A list of profiles [[[StructureDefinition]]]s that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]]." ) 072 protected List<UriType> profile; 073 074 /** 075 * Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure. 076 */ 077 @Child(name = "security", type = {Coding.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 078 @Description(shortDefinition="Security Labels applied to this resource", formalDefinition="Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure." ) 079 protected List<Coding> security; 080 081 /** 082 * Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource. 083 */ 084 @Child(name = "tag", type = {Coding.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 085 @Description(shortDefinition="Tags applied to this resource", formalDefinition="Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource." ) 086 protected List<Coding> tag; 087 088 private static final long serialVersionUID = 867134915L; 089 090 /** 091 * Constructor 092 */ 093 public Meta() { 094 super(); 095 } 096 097 /** 098 * @return {@link #versionId} (The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted.). This is the underlying object with id, value and extensions. The accessor "getVersionId" gives direct access to the value 099 */ 100 public IdType getVersionIdElement() { 101 if (this.versionId == null) 102 if (Configuration.errorOnAutoCreate()) 103 throw new Error("Attempt to auto-create Meta.versionId"); 104 else if (Configuration.doAutoCreate()) 105 this.versionId = new IdType(); // bb 106 return this.versionId; 107 } 108 109 public boolean hasVersionIdElement() { 110 return this.versionId != null && !this.versionId.isEmpty(); 111 } 112 113 public boolean hasVersionId() { 114 return this.versionId != null && !this.versionId.isEmpty(); 115 } 116 117 /** 118 * @param value {@link #versionId} (The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted.). This is the underlying object with id, value and extensions. The accessor "getVersionId" gives direct access to the value 119 */ 120 public Meta setVersionIdElement(IdType value) { 121 this.versionId = value; 122 return this; 123 } 124 125 /** 126 * @return The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted. 127 */ 128 public String getVersionId() { 129 return this.versionId == null ? null : this.versionId.getValue(); 130 } 131 132 /** 133 * @param value The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted. 134 */ 135 public Meta setVersionId(String value) { 136 if (Utilities.noString(value)) 137 this.versionId = null; 138 else { 139 if (this.versionId == null) 140 this.versionId = new IdType(); 141 this.versionId.setValue(value); 142 } 143 return this; 144 } 145 146 /** 147 * @return {@link #lastUpdated} (When the resource last changed - e.g. when the version changed.). This is the underlying object with id, value and extensions. The accessor "getLastUpdated" gives direct access to the value 148 */ 149 public InstantType getLastUpdatedElement() { 150 if (this.lastUpdated == null) 151 if (Configuration.errorOnAutoCreate()) 152 throw new Error("Attempt to auto-create Meta.lastUpdated"); 153 else if (Configuration.doAutoCreate()) 154 this.lastUpdated = new InstantType(); // bb 155 return this.lastUpdated; 156 } 157 158 public boolean hasLastUpdatedElement() { 159 return this.lastUpdated != null && !this.lastUpdated.isEmpty(); 160 } 161 162 public boolean hasLastUpdated() { 163 return this.lastUpdated != null && !this.lastUpdated.isEmpty(); 164 } 165 166 /** 167 * @param value {@link #lastUpdated} (When the resource last changed - e.g. when the version changed.). This is the underlying object with id, value and extensions. The accessor "getLastUpdated" gives direct access to the value 168 */ 169 public Meta setLastUpdatedElement(InstantType value) { 170 this.lastUpdated = value; 171 return this; 172 } 173 174 /** 175 * @return When the resource last changed - e.g. when the version changed. 176 */ 177 public Date getLastUpdated() { 178 return this.lastUpdated == null ? null : this.lastUpdated.getValue(); 179 } 180 181 /** 182 * @param value When the resource last changed - e.g. when the version changed. 183 */ 184 public Meta setLastUpdated(Date value) { 185 if (value == null) 186 this.lastUpdated = null; 187 else { 188 if (this.lastUpdated == null) 189 this.lastUpdated = new InstantType(); 190 this.lastUpdated.setValue(value); 191 } 192 return this; 193 } 194 195 /** 196 * @return {@link #profile} (A list of profiles [[[StructureDefinition]]]s that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].) 197 */ 198 public List<UriType> getProfile() { 199 if (this.profile == null) 200 this.profile = new ArrayList<UriType>(); 201 return this.profile; 202 } 203 204 public boolean hasProfile() { 205 if (this.profile == null) 206 return false; 207 for (UriType item : this.profile) 208 if (!item.isEmpty()) 209 return true; 210 return false; 211 } 212 213 /** 214 * @return {@link #profile} (A list of profiles [[[StructureDefinition]]]s that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].) 215 */ 216 // syntactic sugar 217 public UriType addProfileElement() {//2 218 UriType t = new UriType(); 219 if (this.profile == null) 220 this.profile = new ArrayList<UriType>(); 221 this.profile.add(t); 222 return t; 223 } 224 225 /** 226 * @param value {@link #profile} (A list of profiles [[[StructureDefinition]]]s that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].) 227 */ 228 public Meta addProfile(String value) { //1 229 UriType t = new UriType(); 230 t.setValue(value); 231 if (this.profile == null) 232 this.profile = new ArrayList<UriType>(); 233 this.profile.add(t); 234 return this; 235 } 236 237 /** 238 * @param value {@link #profile} (A list of profiles [[[StructureDefinition]]]s that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].) 239 */ 240 public boolean hasProfile(String value) { 241 if (this.profile == null) 242 return false; 243 for (UriType v : this.profile) 244 if (v.equals(value)) // uri 245 return true; 246 return false; 247 } 248 249 /** 250 * @return {@link #security} (Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.) 251 */ 252 public List<Coding> getSecurity() { 253 if (this.security == null) 254 this.security = new ArrayList<Coding>(); 255 return this.security; 256 } 257 258 public boolean hasSecurity() { 259 if (this.security == null) 260 return false; 261 for (Coding item : this.security) 262 if (!item.isEmpty()) 263 return true; 264 return false; 265 } 266 267 /** 268 * @return {@link #security} (Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.) 269 */ 270 // syntactic sugar 271 public Coding addSecurity() { //3 272 Coding t = new Coding(); 273 if (this.security == null) 274 this.security = new ArrayList<Coding>(); 275 this.security.add(t); 276 return t; 277 } 278 279 // syntactic sugar 280 public Meta addSecurity(Coding t) { //3 281 if (t == null) 282 return this; 283 if (this.security == null) 284 this.security = new ArrayList<Coding>(); 285 this.security.add(t); 286 return this; 287 } 288 289 /** 290 * @return {@link #tag} (Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.) 291 */ 292 public List<Coding> getTag() { 293 if (this.tag == null) 294 this.tag = new ArrayList<Coding>(); 295 return this.tag; 296 } 297 298 public boolean hasTag() { 299 if (this.tag == null) 300 return false; 301 for (Coding item : this.tag) 302 if (!item.isEmpty()) 303 return true; 304 return false; 305 } 306 307 /** 308 * @return {@link #tag} (Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.) 309 */ 310 // syntactic sugar 311 public Coding addTag() { //3 312 Coding t = new Coding(); 313 if (this.tag == null) 314 this.tag = new ArrayList<Coding>(); 315 this.tag.add(t); 316 return t; 317 } 318 319 // syntactic sugar 320 public Meta addTag(Coding t) { //3 321 if (t == null) 322 return this; 323 if (this.tag == null) 324 this.tag = new ArrayList<Coding>(); 325 this.tag.add(t); 326 return this; 327 } 328 329 /** 330 * Convenience method which adds a tag 331 * 332 * @param theSystem The code system 333 * @param theCode The code 334 * @param theDisplay The display name 335 * @return Returns a reference to <code>this</code> for easy chaining 336 */ 337 public Meta addTag(String theSystem, String theCode, String theDisplay) { 338 addTag().setSystem(theSystem).setCode(theCode).setDisplay(theDisplay); 339 return this; 340 } 341 /** 342 * Convenience method which adds a security tag 343 * 344 * @param theSystem The code system 345 * @param theCode The code 346 * @param theDisplay The display name 347 * @return Returns a reference to <code>this</code> for easy chaining 348 */ 349 public Meta addSecurity(String theSystem, String theCode, String theDisplay) { 350 addSecurity().setSystem(theSystem).setCode(theCode).setDisplay(theDisplay); 351 return this; 352 } 353 /** 354 * Returns the first tag (if any) that has the given system and code, or returns 355 * <code>null</code> if none 356 */ 357 public Coding getTag(String theSystem, String theCode) { 358 for (Coding next : getTag()) { 359 if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) { 360 return next; 361 } 362 } 363 return null; 364 } 365 366 /** 367 * Returns the first security label (if any) that has the given system and code, or returns 368 * <code>null</code> if none 369 */ 370 public Coding getSecurity(String theSystem, String theCode) { 371 for (Coding next : getTag()) { 372 if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) { 373 return next; 374 } 375 } 376 return null; 377 } 378 protected void listChildren(List<Property> childrenList) { 379 super.listChildren(childrenList); 380 childrenList.add(new Property("versionId", "id", "The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted.", 0, java.lang.Integer.MAX_VALUE, versionId)); 381 childrenList.add(new Property("lastUpdated", "instant", "When the resource last changed - e.g. when the version changed.", 0, java.lang.Integer.MAX_VALUE, lastUpdated)); 382 childrenList.add(new Property("profile", "uri", "A list of profiles [[[StructureDefinition]]]s that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].", 0, java.lang.Integer.MAX_VALUE, profile)); 383 childrenList.add(new Property("security", "Coding", "Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.", 0, java.lang.Integer.MAX_VALUE, security)); 384 childrenList.add(new Property("tag", "Coding", "Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.", 0, java.lang.Integer.MAX_VALUE, tag)); 385 } 386 387 @Override 388 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 389 switch (hash) { 390 case -1407102957: /*versionId*/ return this.versionId == null ? new Base[0] : new Base[] {this.versionId}; // IdType 391 case 1649733957: /*lastUpdated*/ return this.lastUpdated == null ? new Base[0] : new Base[] {this.lastUpdated}; // InstantType 392 case -309425751: /*profile*/ return this.profile == null ? new Base[0] : this.profile.toArray(new Base[this.profile.size()]); // UriType 393 case 949122880: /*security*/ return this.security == null ? new Base[0] : this.security.toArray(new Base[this.security.size()]); // Coding 394 case 114586: /*tag*/ return this.tag == null ? new Base[0] : this.tag.toArray(new Base[this.tag.size()]); // Coding 395 default: return super.getProperty(hash, name, checkValid); 396 } 397 398 } 399 400 @Override 401 public void setProperty(int hash, String name, Base value) throws FHIRException { 402 switch (hash) { 403 case -1407102957: // versionId 404 this.versionId = castToId(value); // IdType 405 break; 406 case 1649733957: // lastUpdated 407 this.lastUpdated = castToInstant(value); // InstantType 408 break; 409 case -309425751: // profile 410 this.getProfile().add(castToUri(value)); // UriType 411 break; 412 case 949122880: // security 413 this.getSecurity().add(castToCoding(value)); // Coding 414 break; 415 case 114586: // tag 416 this.getTag().add(castToCoding(value)); // Coding 417 break; 418 default: super.setProperty(hash, name, value); 419 } 420 421 } 422 423 @Override 424 public void setProperty(String name, Base value) throws FHIRException { 425 if (name.equals("versionId")) 426 this.versionId = castToId(value); // IdType 427 else if (name.equals("lastUpdated")) 428 this.lastUpdated = castToInstant(value); // InstantType 429 else if (name.equals("profile")) 430 this.getProfile().add(castToUri(value)); 431 else if (name.equals("security")) 432 this.getSecurity().add(castToCoding(value)); 433 else if (name.equals("tag")) 434 this.getTag().add(castToCoding(value)); 435 else 436 super.setProperty(name, value); 437 } 438 439 @Override 440 public Base makeProperty(int hash, String name) throws FHIRException { 441 switch (hash) { 442 case -1407102957: throw new FHIRException("Cannot make property versionId as it is not a complex type"); // IdType 443 case 1649733957: throw new FHIRException("Cannot make property lastUpdated as it is not a complex type"); // InstantType 444 case -309425751: throw new FHIRException("Cannot make property profile as it is not a complex type"); // UriType 445 case 949122880: return addSecurity(); // Coding 446 case 114586: return addTag(); // Coding 447 default: return super.makeProperty(hash, name); 448 } 449 450 } 451 452 @Override 453 public Base addChild(String name) throws FHIRException { 454 if (name.equals("versionId")) { 455 throw new FHIRException("Cannot call addChild on a primitive type Meta.versionId"); 456 } 457 else if (name.equals("lastUpdated")) { 458 throw new FHIRException("Cannot call addChild on a primitive type Meta.lastUpdated"); 459 } 460 else if (name.equals("profile")) { 461 throw new FHIRException("Cannot call addChild on a primitive type Meta.profile"); 462 } 463 else if (name.equals("security")) { 464 return addSecurity(); 465 } 466 else if (name.equals("tag")) { 467 return addTag(); 468 } 469 else 470 return super.addChild(name); 471 } 472 473 public String fhirType() { 474 return "Meta"; 475 476 } 477 478 public Meta copy() { 479 Meta dst = new Meta(); 480 copyValues(dst); 481 dst.versionId = versionId == null ? null : versionId.copy(); 482 dst.lastUpdated = lastUpdated == null ? null : lastUpdated.copy(); 483 if (profile != null) { 484 dst.profile = new ArrayList<UriType>(); 485 for (UriType i : profile) 486 dst.profile.add(i.copy()); 487 }; 488 if (security != null) { 489 dst.security = new ArrayList<Coding>(); 490 for (Coding i : security) 491 dst.security.add(i.copy()); 492 }; 493 if (tag != null) { 494 dst.tag = new ArrayList<Coding>(); 495 for (Coding i : tag) 496 dst.tag.add(i.copy()); 497 }; 498 return dst; 499 } 500 501 protected Meta typedCopy() { 502 return copy(); 503 } 504 505 @Override 506 public boolean equalsDeep(Base other) { 507 if (!super.equalsDeep(other)) 508 return false; 509 if (!(other instanceof Meta)) 510 return false; 511 Meta o = (Meta) other; 512 return compareDeep(versionId, o.versionId, true) && compareDeep(lastUpdated, o.lastUpdated, true) 513 && compareDeep(profile, o.profile, true) && compareDeep(security, o.security, true) && compareDeep(tag, o.tag, true) 514 ; 515 } 516 517 @Override 518 public boolean equalsShallow(Base other) { 519 if (!super.equalsShallow(other)) 520 return false; 521 if (!(other instanceof Meta)) 522 return false; 523 Meta o = (Meta) other; 524 return compareValues(versionId, o.versionId, true) && compareValues(lastUpdated, o.lastUpdated, true) 525 && compareValues(profile, o.profile, true); 526 } 527 528 public boolean isEmpty() { 529 return super.isEmpty() && (versionId == null || versionId.isEmpty()) && (lastUpdated == null || lastUpdated.isEmpty()) 530 && (profile == null || profile.isEmpty()) && (security == null || security.isEmpty()) && (tag == null || tag.isEmpty()) 531 ; 532 } 533 534 535}