001package org.hl7.fhir.r4.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 Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0 033 034import java.util.*; 035 036import org.hl7.fhir.utilities.Utilities; 037import org.hl7.fhir.r4.model.Enumerations.*; 038import ca.uhn.fhir.model.api.annotation.ResourceDef; 039import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 040import ca.uhn.fhir.model.api.annotation.Child; 041import ca.uhn.fhir.model.api.annotation.ChildOrder; 042import ca.uhn.fhir.model.api.annotation.Description; 043import ca.uhn.fhir.model.api.annotation.Block; 044import org.hl7.fhir.instance.model.api.*; 045import org.hl7.fhir.exceptions.FHIRException; 046/** 047 * A resource that represents the data of a single raw artifact as digital content accessible in its native format. A Binary resource can contain any content, whether text, image, pdf, zip archive, etc. 048 */ 049@ResourceDef(name="Binary", profile="http://hl7.org/fhir/StructureDefinition/Binary") 050public class Binary extends BaseBinary implements IBaseBinary { 051 052 /** 053 * MimeType of the binary content represented as a standard MimeType (BCP 13). 054 */ 055 @Child(name = "contentType", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true) 056 @Description(shortDefinition="MimeType of the binary content", formalDefinition="MimeType of the binary content represented as a standard MimeType (BCP 13)." ) 057 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/mimetypes") 058 protected CodeType contentType; 059 060 /** 061 * This element identifies another resource that can be used as a proxy of the security sensitivity to use when deciding and enforcing access control rules for the Binary resource. Given that the Binary resource contains very few elements that can be used to determine the sensitivity of the data and relationships to individuals, the referenced resource stands in as a proxy equivalent for this purpose. This referenced resource may be related to the Binary (e.g. Media, DocumentReference), or may be some non-related Resource purely as a security proxy. E.g. to identify that the binary resource relates to a patient, and access should only be granted to applications that have access to the patient. 062 */ 063 @Child(name = "securityContext", type = {Reference.class}, order=1, min=0, max=1, modifier=false, summary=true) 064 @Description(shortDefinition="Identifies another resource to use as proxy when enforcing access control", formalDefinition="This element identifies another resource that can be used as a proxy of the security sensitivity to use when deciding and enforcing access control rules for the Binary resource. Given that the Binary resource contains very few elements that can be used to determine the sensitivity of the data and relationships to individuals, the referenced resource stands in as a proxy equivalent for this purpose. This referenced resource may be related to the Binary (e.g. Media, DocumentReference), or may be some non-related Resource purely as a security proxy. E.g. to identify that the binary resource relates to a patient, and access should only be granted to applications that have access to the patient." ) 065 protected Reference securityContext; 066 067 /** 068 * The actual object that is the target of the reference (This element identifies another resource that can be used as a proxy of the security sensitivity to use when deciding and enforcing access control rules for the Binary resource. Given that the Binary resource contains very few elements that can be used to determine the sensitivity of the data and relationships to individuals, the referenced resource stands in as a proxy equivalent for this purpose. This referenced resource may be related to the Binary (e.g. Media, DocumentReference), or may be some non-related Resource purely as a security proxy. E.g. to identify that the binary resource relates to a patient, and access should only be granted to applications that have access to the patient.) 069 */ 070 protected Resource securityContextTarget; 071 072 /** 073 * The actual content, base64 encoded. 074 */ 075 @Child(name = "data", type = {Base64BinaryType.class}, order=2, min=0, max=1, modifier=false, summary=false) 076 @Description(shortDefinition="The actual content", formalDefinition="The actual content, base64 encoded." ) 077 protected Base64BinaryType data; 078 079 private static final long serialVersionUID = 1353224198L; 080 081 /** 082 * Constructor 083 */ 084 public Binary() { 085 super(); 086 } 087 088 /** 089 * Constructor 090 */ 091 public Binary(CodeType contentType) { 092 super(); 093 this.contentType = contentType; 094 } 095 096 /** 097 * @return {@link #contentType} (MimeType of the binary content represented as a standard MimeType (BCP 13).). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value 098 */ 099 public CodeType getContentTypeElement() { 100 if (this.contentType == null) 101 if (Configuration.errorOnAutoCreate()) 102 throw new Error("Attempt to auto-create Binary.contentType"); 103 else if (Configuration.doAutoCreate()) 104 this.contentType = new CodeType(); // bb 105 return this.contentType; 106 } 107 108 public boolean hasContentTypeElement() { 109 return this.contentType != null && !this.contentType.isEmpty(); 110 } 111 112 public boolean hasContentType() { 113 return this.contentType != null && !this.contentType.isEmpty(); 114 } 115 116 /** 117 * @param value {@link #contentType} (MimeType of the binary content represented as a standard MimeType (BCP 13).). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value 118 */ 119 public Binary setContentTypeElement(CodeType value) { 120 this.contentType = value; 121 return this; 122 } 123 124 /** 125 * @return MimeType of the binary content represented as a standard MimeType (BCP 13). 126 */ 127 public String getContentType() { 128 return this.contentType == null ? null : this.contentType.getValue(); 129 } 130 131 /** 132 * @param value MimeType of the binary content represented as a standard MimeType (BCP 13). 133 */ 134 public Binary setContentType(String value) { 135 if (this.contentType == null) 136 this.contentType = new CodeType(); 137 this.contentType.setValue(value); 138 return this; 139 } 140 141 /** 142 * @return {@link #securityContext} (This element identifies another resource that can be used as a proxy of the security sensitivity to use when deciding and enforcing access control rules for the Binary resource. Given that the Binary resource contains very few elements that can be used to determine the sensitivity of the data and relationships to individuals, the referenced resource stands in as a proxy equivalent for this purpose. This referenced resource may be related to the Binary (e.g. Media, DocumentReference), or may be some non-related Resource purely as a security proxy. E.g. to identify that the binary resource relates to a patient, and access should only be granted to applications that have access to the patient.) 143 */ 144 public Reference getSecurityContext() { 145 if (this.securityContext == null) 146 if (Configuration.errorOnAutoCreate()) 147 throw new Error("Attempt to auto-create Binary.securityContext"); 148 else if (Configuration.doAutoCreate()) 149 this.securityContext = new Reference(); // cc 150 return this.securityContext; 151 } 152 153 public boolean hasSecurityContext() { 154 return this.securityContext != null && !this.securityContext.isEmpty(); 155 } 156 157 /** 158 * @param value {@link #securityContext} (This element identifies another resource that can be used as a proxy of the security sensitivity to use when deciding and enforcing access control rules for the Binary resource. Given that the Binary resource contains very few elements that can be used to determine the sensitivity of the data and relationships to individuals, the referenced resource stands in as a proxy equivalent for this purpose. This referenced resource may be related to the Binary (e.g. Media, DocumentReference), or may be some non-related Resource purely as a security proxy. E.g. to identify that the binary resource relates to a patient, and access should only be granted to applications that have access to the patient.) 159 */ 160 public Binary setSecurityContext(Reference value) { 161 this.securityContext = value; 162 return this; 163 } 164 165 /** 166 * @return {@link #securityContext} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (This element identifies another resource that can be used as a proxy of the security sensitivity to use when deciding and enforcing access control rules for the Binary resource. Given that the Binary resource contains very few elements that can be used to determine the sensitivity of the data and relationships to individuals, the referenced resource stands in as a proxy equivalent for this purpose. This referenced resource may be related to the Binary (e.g. Media, DocumentReference), or may be some non-related Resource purely as a security proxy. E.g. to identify that the binary resource relates to a patient, and access should only be granted to applications that have access to the patient.) 167 */ 168 public Resource getSecurityContextTarget() { 169 return this.securityContextTarget; 170 } 171 172 /** 173 * @param value {@link #securityContext} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (This element identifies another resource that can be used as a proxy of the security sensitivity to use when deciding and enforcing access control rules for the Binary resource. Given that the Binary resource contains very few elements that can be used to determine the sensitivity of the data and relationships to individuals, the referenced resource stands in as a proxy equivalent for this purpose. This referenced resource may be related to the Binary (e.g. Media, DocumentReference), or may be some non-related Resource purely as a security proxy. E.g. to identify that the binary resource relates to a patient, and access should only be granted to applications that have access to the patient.) 174 */ 175 public Binary setSecurityContextTarget(Resource value) { 176 this.securityContextTarget = value; 177 return this; 178 } 179 180 /** 181 * @return {@link #data} (The actual content, base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value 182 */ 183 public Base64BinaryType getDataElement() { 184 if (this.data == null) 185 if (Configuration.errorOnAutoCreate()) 186 throw new Error("Attempt to auto-create Binary.data"); 187 else if (Configuration.doAutoCreate()) 188 this.data = new Base64BinaryType(); // bb 189 return this.data; 190 } 191 192 public boolean hasDataElement() { 193 return this.data != null && !this.data.isEmpty(); 194 } 195 196 public boolean hasData() { 197 return this.data != null && !this.data.isEmpty(); 198 } 199 200 /** 201 * @param value {@link #data} (The actual content, base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value 202 */ 203 public Binary setDataElement(Base64BinaryType value) { 204 this.data = value; 205 return this; 206 } 207 208 /** 209 * @return The actual content, base64 encoded. 210 */ 211 public byte[] getData() { 212 return this.data == null ? null : this.data.getValue(); 213 } 214 215 /** 216 * @param value The actual content, base64 encoded. 217 */ 218 public Binary setData(byte[] value) { 219 if (value == null) 220 this.data = null; 221 else { 222 if (this.data == null) 223 this.data = new Base64BinaryType(); 224 this.data.setValue(value); 225 } 226 return this; 227 } 228 229 protected void listChildren(List<Property> children) { 230 super.listChildren(children); 231 children.add(new Property("contentType", "code", "MimeType of the binary content represented as a standard MimeType (BCP 13).", 0, 1, contentType)); 232 children.add(new Property("securityContext", "Reference(Any)", "This element identifies another resource that can be used as a proxy of the security sensitivity to use when deciding and enforcing access control rules for the Binary resource. Given that the Binary resource contains very few elements that can be used to determine the sensitivity of the data and relationships to individuals, the referenced resource stands in as a proxy equivalent for this purpose. This referenced resource may be related to the Binary (e.g. Media, DocumentReference), or may be some non-related Resource purely as a security proxy. E.g. to identify that the binary resource relates to a patient, and access should only be granted to applications that have access to the patient.", 0, 1, securityContext)); 233 children.add(new Property("data", "base64Binary", "The actual content, base64 encoded.", 0, 1, data)); 234 } 235 236 @Override 237 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 238 switch (_hash) { 239 case -389131437: /*contentType*/ return new Property("contentType", "code", "MimeType of the binary content represented as a standard MimeType (BCP 13).", 0, 1, contentType); 240 case -1622888881: /*securityContext*/ return new Property("securityContext", "Reference(Any)", "This element identifies another resource that can be used as a proxy of the security sensitivity to use when deciding and enforcing access control rules for the Binary resource. Given that the Binary resource contains very few elements that can be used to determine the sensitivity of the data and relationships to individuals, the referenced resource stands in as a proxy equivalent for this purpose. This referenced resource may be related to the Binary (e.g. Media, DocumentReference), or may be some non-related Resource purely as a security proxy. E.g. to identify that the binary resource relates to a patient, and access should only be granted to applications that have access to the patient.", 0, 1, securityContext); 241 case 3076010: /*data*/ return new Property("data", "base64Binary", "The actual content, base64 encoded.", 0, 1, data); 242 default: return super.getNamedProperty(_hash, _name, _checkValid); 243 } 244 245 } 246 247 @Override 248 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 249 switch (hash) { 250 case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType 251 case -1622888881: /*securityContext*/ return this.securityContext == null ? new Base[0] : new Base[] {this.securityContext}; // Reference 252 case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // Base64BinaryType 253 default: return super.getProperty(hash, name, checkValid); 254 } 255 256 } 257 258 @Override 259 public Base setProperty(int hash, String name, Base value) throws FHIRException { 260 switch (hash) { 261 case -389131437: // contentType 262 this.contentType = castToCode(value); // CodeType 263 return value; 264 case -1622888881: // securityContext 265 this.securityContext = castToReference(value); // Reference 266 return value; 267 case 3076010: // data 268 this.data = castToBase64Binary(value); // Base64BinaryType 269 return value; 270 default: return super.setProperty(hash, name, value); 271 } 272 273 } 274 275 @Override 276 public Base setProperty(String name, Base value) throws FHIRException { 277 if (name.equals("contentType")) { 278 this.contentType = castToCode(value); // CodeType 279 } else if (name.equals("securityContext")) { 280 this.securityContext = castToReference(value); // Reference 281 } else if (name.equals("data")) { 282 this.data = castToBase64Binary(value); // Base64BinaryType 283 } else 284 return super.setProperty(name, value); 285 return value; 286 } 287 288 @Override 289 public Base makeProperty(int hash, String name) throws FHIRException { 290 switch (hash) { 291 case -389131437: return getContentTypeElement(); 292 case -1622888881: return getSecurityContext(); 293 case 3076010: return getDataElement(); 294 default: return super.makeProperty(hash, name); 295 } 296 297 } 298 299 @Override 300 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 301 switch (hash) { 302 case -389131437: /*contentType*/ return new String[] {"code"}; 303 case -1622888881: /*securityContext*/ return new String[] {"Reference"}; 304 case 3076010: /*data*/ return new String[] {"base64Binary"}; 305 default: return super.getTypesForProperty(hash, name); 306 } 307 308 } 309 310 @Override 311 public Base addChild(String name) throws FHIRException { 312 if (name.equals("contentType")) { 313 throw new FHIRException("Cannot call addChild on a primitive type Binary.contentType"); 314 } 315 else if (name.equals("securityContext")) { 316 this.securityContext = new Reference(); 317 return this.securityContext; 318 } 319 else if (name.equals("data")) { 320 throw new FHIRException("Cannot call addChild on a primitive type Binary.data"); 321 } 322 else 323 return super.addChild(name); 324 } 325 326 public String fhirType() { 327 return "Binary"; 328 329 } 330 331 public Binary copy() { 332 Binary dst = new Binary(); 333 copyValues(dst); 334 dst.contentType = contentType == null ? null : contentType.copy(); 335 dst.securityContext = securityContext == null ? null : securityContext.copy(); 336 dst.data = data == null ? null : data.copy(); 337 return dst; 338 } 339 340 protected Binary typedCopy() { 341 return copy(); 342 } 343 344 @Override 345 public boolean equalsDeep(Base other_) { 346 if (!super.equalsDeep(other_)) 347 return false; 348 if (!(other_ instanceof Binary)) 349 return false; 350 Binary o = (Binary) other_; 351 return compareDeep(contentType, o.contentType, true) && compareDeep(securityContext, o.securityContext, true) 352 && compareDeep(data, o.data, true); 353 } 354 355 @Override 356 public boolean equalsShallow(Base other_) { 357 if (!super.equalsShallow(other_)) 358 return false; 359 if (!(other_ instanceof Binary)) 360 return false; 361 Binary o = (Binary) other_; 362 return compareValues(contentType, o.contentType, true) && compareValues(data, o.data, true); 363 } 364 365 public boolean isEmpty() { 366 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(contentType, securityContext 367 , data); 368 } 369 370 @Override 371 public ResourceType getResourceType() { 372 return ResourceType.Binary; 373 } 374 375// added from java-adornments.txt: 376 377 @Override 378 public byte[] getContent() { 379 return getData(); 380 } 381 382 @Override 383 public IBaseBinary setContent(byte[] arg0) { 384 return setData(arg0); 385 } 386 387 @Override 388 Base64BinaryType getContentElement() { 389 return getDataElement(); 390 } 391 392 393 394// end addition 395 396} 397