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