001package org.hl7.fhir.r4.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.r4 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 Copyright (c) 2011+, HL7, Inc. 025 All rights reserved. 026 027 Redistribution and use in source and binary forms, with or without modification, 028 are permitted provided that the following conditions are met: 029 030 * Redistributions of source code must retain the above copyright notice, this 031 list of conditions and the following disclaimer. 032 * Redistributions in binary form must reproduce the above copyright notice, 033 this list of conditions and the following disclaimer in the documentation 034 and/or other materials provided with the distribution. 035 * Neither the name of HL7 nor the names of its contributors may be used to 036 endorse or promote products derived from this software without specific 037 prior written permission. 038 039 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 040 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 041 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 042 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 043 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 044 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 045 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 046 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 047 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 048 POSSIBILITY OF SUCH DAMAGE. 049 050*/ 051 052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0 053import java.util.List; 054 055import org.hl7.fhir.exceptions.FHIRException; 056import org.hl7.fhir.instance.model.api.IBaseBinary; 057 058import ca.uhn.fhir.model.api.annotation.Child; 059import ca.uhn.fhir.model.api.annotation.Description; 060import ca.uhn.fhir.model.api.annotation.ResourceDef; 061/** 062 * 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. 063 */ 064@ResourceDef(name="Binary", profile="http://hl7.org/fhir/StructureDefinition/Binary") 065public class Binary extends BaseBinary implements IBaseBinary { 066 067 /** 068 * MimeType of the binary content represented as a standard MimeType (BCP 13). 069 */ 070 @Child(name = "contentType", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true) 071 @Description(shortDefinition="MimeType of the binary content", formalDefinition="MimeType of the binary content represented as a standard MimeType (BCP 13)." ) 072 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/mimetypes") 073 protected CodeType contentType; 074 075 /** 076 * 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. 077 */ 078 @Child(name = "securityContext", type = {Reference.class}, order=1, min=0, max=1, modifier=false, summary=true) 079 @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." ) 080 protected Reference securityContext; 081 082 /** 083 * 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.) 084 */ 085 protected Resource securityContextTarget; 086 087 /** 088 * The actual content, base64 encoded. 089 */ 090 @Child(name = "data", type = {Base64BinaryType.class}, order=2, min=0, max=1, modifier=false, summary=false) 091 @Description(shortDefinition="The actual content", formalDefinition="The actual content, base64 encoded." ) 092 protected Base64BinaryType data; 093 094 private static final long serialVersionUID = 1353224198L; 095 096 /** 097 * Constructor 098 */ 099 public Binary() { 100 super(); 101 } 102 103 /** 104 * Constructor 105 */ 106 public Binary(CodeType contentType) { 107 super(); 108 this.contentType = contentType; 109 } 110 111 /** 112 * @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 113 */ 114 public CodeType getContentTypeElement() { 115 if (this.contentType == null) 116 if (Configuration.errorOnAutoCreate()) 117 throw new Error("Attempt to auto-create Binary.contentType"); 118 else if (Configuration.doAutoCreate()) 119 this.contentType = new CodeType(); // bb 120 return this.contentType; 121 } 122 123 public boolean hasContentTypeElement() { 124 return this.contentType != null && !this.contentType.isEmpty(); 125 } 126 127 public boolean hasContentType() { 128 return this.contentType != null && !this.contentType.isEmpty(); 129 } 130 131 /** 132 * @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 133 */ 134 public Binary setContentTypeElement(CodeType value) { 135 this.contentType = value; 136 return this; 137 } 138 139 /** 140 * @return MimeType of the binary content represented as a standard MimeType (BCP 13). 141 */ 142 public String getContentType() { 143 return this.contentType == null ? null : this.contentType.getValue(); 144 } 145 146 /** 147 * @param value MimeType of the binary content represented as a standard MimeType (BCP 13). 148 */ 149 public Binary setContentType(String value) { 150 if (this.contentType == null) 151 this.contentType = new CodeType(); 152 this.contentType.setValue(value); 153 return this; 154 } 155 156 /** 157 * @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.) 158 */ 159 public Reference getSecurityContext() { 160 if (this.securityContext == null) 161 if (Configuration.errorOnAutoCreate()) 162 throw new Error("Attempt to auto-create Binary.securityContext"); 163 else if (Configuration.doAutoCreate()) 164 this.securityContext = new Reference(); // cc 165 return this.securityContext; 166 } 167 168 public boolean hasSecurityContext() { 169 return this.securityContext != null && !this.securityContext.isEmpty(); 170 } 171 172 /** 173 * @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.) 174 */ 175 public Binary setSecurityContext(Reference value) { 176 this.securityContext = value; 177 return this; 178 } 179 180 /** 181 * @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.) 182 */ 183 public Resource getSecurityContextTarget() { 184 return this.securityContextTarget; 185 } 186 187 /** 188 * @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.) 189 */ 190 public Binary setSecurityContextTarget(Resource value) { 191 this.securityContextTarget = value; 192 return this; 193 } 194 195 /** 196 * @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 197 */ 198 public Base64BinaryType getDataElement() { 199 if (this.data == null) 200 if (Configuration.errorOnAutoCreate()) 201 throw new Error("Attempt to auto-create Binary.data"); 202 else if (Configuration.doAutoCreate()) 203 this.data = new Base64BinaryType(); // bb 204 return this.data; 205 } 206 207 public boolean hasDataElement() { 208 return this.data != null && !this.data.isEmpty(); 209 } 210 211 public boolean hasData() { 212 return this.data != null && !this.data.isEmpty(); 213 } 214 215 /** 216 * @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 217 */ 218 public Binary setDataElement(Base64BinaryType value) { 219 this.data = value; 220 return this; 221 } 222 223 /** 224 * @return The actual content, base64 encoded. 225 */ 226 public byte[] getData() { 227 return this.data == null ? null : this.data.getValue(); 228 } 229 230 /** 231 * @param value The actual content, base64 encoded. 232 */ 233 public Binary setData(byte[] value) { 234 if (value == null) 235 this.data = null; 236 else { 237 if (this.data == null) 238 this.data = new Base64BinaryType(); 239 this.data.setValue(value); 240 } 241 return this; 242 } 243 244 protected void listChildren(List<Property> children) { 245 super.listChildren(children); 246 children.add(new Property("contentType", "code", "MimeType of the binary content represented as a standard MimeType (BCP 13).", 0, 1, contentType)); 247 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)); 248 children.add(new Property("data", "base64Binary", "The actual content, base64 encoded.", 0, 1, data)); 249 } 250 251 @Override 252 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 253 switch (_hash) { 254 case -389131437: /*contentType*/ return new Property("contentType", "code", "MimeType of the binary content represented as a standard MimeType (BCP 13).", 0, 1, contentType); 255 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); 256 case 3076010: /*data*/ return new Property("data", "base64Binary", "The actual content, base64 encoded.", 0, 1, data); 257 default: return super.getNamedProperty(_hash, _name, _checkValid); 258 } 259 260 } 261 262 @Override 263 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 264 switch (hash) { 265 case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType 266 case -1622888881: /*securityContext*/ return this.securityContext == null ? new Base[0] : new Base[] {this.securityContext}; // Reference 267 case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // Base64BinaryType 268 default: return super.getProperty(hash, name, checkValid); 269 } 270 271 } 272 273 @Override 274 public Base setProperty(int hash, String name, Base value) throws FHIRException { 275 switch (hash) { 276 case -389131437: // contentType 277 this.contentType = castToCode(value); // CodeType 278 return value; 279 case -1622888881: // securityContext 280 this.securityContext = castToReference(value); // Reference 281 return value; 282 case 3076010: // data 283 this.data = castToBase64Binary(value); // Base64BinaryType 284 return value; 285 default: return super.setProperty(hash, name, value); 286 } 287 288 } 289 290 @Override 291 public Base setProperty(String name, Base value) throws FHIRException { 292 if (name.equals("contentType")) { 293 this.contentType = castToCode(value); // CodeType 294 } else if (name.equals("securityContext")) { 295 this.securityContext = castToReference(value); // Reference 296 } else if (name.equals("data")) { 297 this.data = castToBase64Binary(value); // Base64BinaryType 298 } else 299 return super.setProperty(name, value); 300 return value; 301 } 302 303 @Override 304 public Base makeProperty(int hash, String name) throws FHIRException { 305 switch (hash) { 306 case -389131437: return getContentTypeElement(); 307 case -1622888881: return getSecurityContext(); 308 case 3076010: return getDataElement(); 309 default: return super.makeProperty(hash, name); 310 } 311 312 } 313 314 @Override 315 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 316 switch (hash) { 317 case -389131437: /*contentType*/ return new String[] {"code"}; 318 case -1622888881: /*securityContext*/ return new String[] {"Reference"}; 319 case 3076010: /*data*/ return new String[] {"base64Binary"}; 320 default: return super.getTypesForProperty(hash, name); 321 } 322 323 } 324 325 @Override 326 public Base addChild(String name) throws FHIRException { 327 if (name.equals("contentType")) { 328 throw new FHIRException("Cannot call addChild on a primitive type Binary.contentType"); 329 } 330 else if (name.equals("securityContext")) { 331 this.securityContext = new Reference(); 332 return this.securityContext; 333 } 334 else if (name.equals("data")) { 335 throw new FHIRException("Cannot call addChild on a primitive type Binary.data"); 336 } 337 else 338 return super.addChild(name); 339 } 340 341 public String fhirType() { 342 return "Binary"; 343 344 } 345 346 public Binary copy() { 347 Binary dst = new Binary(); 348 copyValues(dst); 349 dst.contentType = contentType == null ? null : contentType.copy(); 350 dst.securityContext = securityContext == null ? null : securityContext.copy(); 351 dst.data = data == null ? null : data.copy(); 352 return dst; 353 } 354 355 protected Binary typedCopy() { 356 return copy(); 357 } 358 359 @Override 360 public boolean equalsDeep(Base other_) { 361 if (!super.equalsDeep(other_)) 362 return false; 363 if (!(other_ instanceof Binary)) 364 return false; 365 Binary o = (Binary) other_; 366 return compareDeep(contentType, o.contentType, true) && compareDeep(securityContext, o.securityContext, true) 367 && compareDeep(data, o.data, true); 368 } 369 370 @Override 371 public boolean equalsShallow(Base other_) { 372 if (!super.equalsShallow(other_)) 373 return false; 374 if (!(other_ instanceof Binary)) 375 return false; 376 Binary o = (Binary) other_; 377 return compareValues(contentType, o.contentType, true) && compareValues(data, o.data, true); 378 } 379 380 public boolean isEmpty() { 381 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(contentType, securityContext 382 , data); 383 } 384 385 @Override 386 public ResourceType getResourceType() { 387 return ResourceType.Binary; 388 } 389 390// added from java-adornments.txt: 391 392 @Override 393 public byte[] getContent() { 394 return getData(); 395 } 396 397 @Override 398 public IBaseBinary setContent(byte[] arg0) { 399 return setData(arg0); 400 } 401 402 @Override 403 public Base64BinaryType getContentElement() { 404 return getDataElement(); 405 } 406 407 408 409// end addition 410 411} 412