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