001package org.hl7.fhir.dstu3.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 Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.1 033 034import java.util.*; 035 036import org.hl7.fhir.utilities.Utilities; 037import org.hl7.fhir.dstu3.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; 046import org.hl7.fhir.exceptions.FHIRFormatError; 047/** 048 * A binary resource can contain any content, whether text, image, pdf, zip archive, etc. 049 */ 050@ResourceDef(name="Binary", profile="http://hl7.org/fhir/StructureDefinition/Binary") 051public class Binary extends BaseBinary implements IBaseBinary { 052 053 /** 054 * MimeType of the binary content represented as a standard MimeType (BCP 13). 055 */ 056 @Child(name = "contentType", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true) 057 @Description(shortDefinition="MimeType of the binary content", formalDefinition="MimeType of the binary content represented as a standard MimeType (BCP 13)." ) 058 protected CodeType contentType; 059 060 /** 061 * Treat this binary as if it was this other resource for access control purposes. 062 */ 063 @Child(name = "securityContext", type = {Reference.class}, order=1, min=0, max=1, modifier=false, summary=true) 064 @Description(shortDefinition="Access Control Management", formalDefinition="Treat this binary as if it was this other resource for access control purposes." ) 065 protected Reference securityContext; 066 067 /** 068 * The actual object that is the target of the reference (Treat this binary as if it was this other resource for access control purposes.) 069 */ 070 protected Resource securityContextTarget; 071 072 /** 073 * The actual content, base64 encoded. 074 */ 075 @Child(name = "content", type = {Base64BinaryType.class}, order=2, min=1, max=1, modifier=false, summary=false) 076 @Description(shortDefinition="The actual content", formalDefinition="The actual content, base64 encoded." ) 077 protected Base64BinaryType content; 078 079 private static final long serialVersionUID = 1111991335L; 080 081 /** 082 * Constructor 083 */ 084 public Binary() { 085 super(); 086 } 087 088 /** 089 * Constructor 090 */ 091 public Binary(CodeType contentType, Base64BinaryType content) { 092 super(); 093 this.contentType = contentType; 094 this.content = content; 095 } 096 097 /** 098 * @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 099 */ 100 public CodeType getContentTypeElement() { 101 if (this.contentType == null) 102 if (Configuration.errorOnAutoCreate()) 103 throw new Error("Attempt to auto-create Binary.contentType"); 104 else if (Configuration.doAutoCreate()) 105 this.contentType = new CodeType(); // bb 106 return this.contentType; 107 } 108 109 public boolean hasContentTypeElement() { 110 return this.contentType != null && !this.contentType.isEmpty(); 111 } 112 113 public boolean hasContentType() { 114 return this.contentType != null && !this.contentType.isEmpty(); 115 } 116 117 /** 118 * @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 119 */ 120 public Binary setContentTypeElement(CodeType value) { 121 this.contentType = value; 122 return this; 123 } 124 125 /** 126 * @return MimeType of the binary content represented as a standard MimeType (BCP 13). 127 */ 128 public String getContentType() { 129 return this.contentType == null ? null : this.contentType.getValue(); 130 } 131 132 /** 133 * @param value MimeType of the binary content represented as a standard MimeType (BCP 13). 134 */ 135 public Binary setContentType(String value) { 136 if (this.contentType == null) 137 this.contentType = new CodeType(); 138 this.contentType.setValue(value); 139 return this; 140 } 141 142 /** 143 * @return {@link #securityContext} (Treat this binary as if it was this other resource for access control purposes.) 144 */ 145 public Reference getSecurityContext() { 146 if (this.securityContext == null) 147 if (Configuration.errorOnAutoCreate()) 148 throw new Error("Attempt to auto-create Binary.securityContext"); 149 else if (Configuration.doAutoCreate()) 150 this.securityContext = new Reference(); // cc 151 return this.securityContext; 152 } 153 154 public boolean hasSecurityContext() { 155 return this.securityContext != null && !this.securityContext.isEmpty(); 156 } 157 158 /** 159 * @param value {@link #securityContext} (Treat this binary as if it was this other resource for access control purposes.) 160 */ 161 public Binary setSecurityContext(Reference value) { 162 this.securityContext = value; 163 return this; 164 } 165 166 /** 167 * @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. (Treat this binary as if it was this other resource for access control purposes.) 168 */ 169 public Resource getSecurityContextTarget() { 170 return this.securityContextTarget; 171 } 172 173 /** 174 * @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. (Treat this binary as if it was this other resource for access control purposes.) 175 */ 176 public Binary setSecurityContextTarget(Resource value) { 177 this.securityContextTarget = value; 178 return this; 179 } 180 181 /** 182 * @return {@link #content} (The actual content, base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getContent" gives direct access to the value 183 */ 184 public Base64BinaryType getContentElement() { 185 if (this.content == null) 186 if (Configuration.errorOnAutoCreate()) 187 throw new Error("Attempt to auto-create Binary.content"); 188 else if (Configuration.doAutoCreate()) 189 this.content = new Base64BinaryType(); // bb 190 return this.content; 191 } 192 193 public boolean hasContentElement() { 194 return this.content != null && !this.content.isEmpty(); 195 } 196 197 public boolean hasContent() { 198 return this.content != null && !this.content.isEmpty(); 199 } 200 201 /** 202 * @param value {@link #content} (The actual content, base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getContent" gives direct access to the value 203 */ 204 public Binary setContentElement(Base64BinaryType value) { 205 this.content = value; 206 return this; 207 } 208 209 /** 210 * @return The actual content, base64 encoded. 211 */ 212 public byte[] getContent() { 213 return this.content == null ? null : this.content.getValue(); 214 } 215 216 /** 217 * @param value The actual content, base64 encoded. 218 */ 219 public Binary setContent(byte[] value) { 220 if (this.content == null) 221 this.content = new Base64BinaryType(); 222 this.content.setValue(value); 223 return this; 224 } 225 226 protected void listChildren(List<Property> children) { 227 super.listChildren(children); 228 children.add(new Property("contentType", "code", "MimeType of the binary content represented as a standard MimeType (BCP 13).", 0, 1, contentType)); 229 children.add(new Property("securityContext", "Reference(Any)", "Treat this binary as if it was this other resource for access control purposes.", 0, 1, securityContext)); 230 children.add(new Property("content", "base64Binary", "The actual content, base64 encoded.", 0, 1, content)); 231 } 232 233 @Override 234 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 235 switch (_hash) { 236 case -389131437: /*contentType*/ return new Property("contentType", "code", "MimeType of the binary content represented as a standard MimeType (BCP 13).", 0, 1, contentType); 237 case -1622888881: /*securityContext*/ return new Property("securityContext", "Reference(Any)", "Treat this binary as if it was this other resource for access control purposes.", 0, 1, securityContext); 238 case 951530617: /*content*/ return new Property("content", "base64Binary", "The actual content, base64 encoded.", 0, 1, content); 239 default: return super.getNamedProperty(_hash, _name, _checkValid); 240 } 241 242 } 243 244 @Override 245 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 246 switch (hash) { 247 case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType 248 case -1622888881: /*securityContext*/ return this.securityContext == null ? new Base[0] : new Base[] {this.securityContext}; // Reference 249 case 951530617: /*content*/ return this.content == null ? new Base[0] : new Base[] {this.content}; // Base64BinaryType 250 default: return super.getProperty(hash, name, checkValid); 251 } 252 253 } 254 255 @Override 256 public Base setProperty(int hash, String name, Base value) throws FHIRException { 257 switch (hash) { 258 case -389131437: // contentType 259 this.contentType = castToCode(value); // CodeType 260 return value; 261 case -1622888881: // securityContext 262 this.securityContext = castToReference(value); // Reference 263 return value; 264 case 951530617: // content 265 this.content = castToBase64Binary(value); // Base64BinaryType 266 return value; 267 default: return super.setProperty(hash, name, value); 268 } 269 270 } 271 272 @Override 273 public Base setProperty(String name, Base value) throws FHIRException { 274 if (name.equals("contentType")) { 275 this.contentType = castToCode(value); // CodeType 276 } else if (name.equals("securityContext")) { 277 this.securityContext = castToReference(value); // Reference 278 } else if (name.equals("content")) { 279 this.content = castToBase64Binary(value); // Base64BinaryType 280 } else 281 return super.setProperty(name, value); 282 return value; 283 } 284 285 @Override 286 public Base makeProperty(int hash, String name) throws FHIRException { 287 switch (hash) { 288 case -389131437: return getContentTypeElement(); 289 case -1622888881: return getSecurityContext(); 290 case 951530617: return getContentElement(); 291 default: return super.makeProperty(hash, name); 292 } 293 294 } 295 296 @Override 297 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 298 switch (hash) { 299 case -389131437: /*contentType*/ return new String[] {"code"}; 300 case -1622888881: /*securityContext*/ return new String[] {"Reference"}; 301 case 951530617: /*content*/ return new String[] {"base64Binary"}; 302 default: return super.getTypesForProperty(hash, name); 303 } 304 305 } 306 307 @Override 308 public Base addChild(String name) throws FHIRException { 309 if (name.equals("contentType")) { 310 throw new FHIRException("Cannot call addChild on a primitive type Binary.contentType"); 311 } 312 else if (name.equals("securityContext")) { 313 this.securityContext = new Reference(); 314 return this.securityContext; 315 } 316 else if (name.equals("content")) { 317 throw new FHIRException("Cannot call addChild on a primitive type Binary.content"); 318 } 319 else 320 return super.addChild(name); 321 } 322 323 public String fhirType() { 324 return "Binary"; 325 326 } 327 328 public Binary copy() { 329 Binary dst = new Binary(); 330 copyValues(dst); 331 dst.contentType = contentType == null ? null : contentType.copy(); 332 dst.securityContext = securityContext == null ? null : securityContext.copy(); 333 dst.content = content == null ? null : content.copy(); 334 return dst; 335 } 336 337 protected Binary typedCopy() { 338 return copy(); 339 } 340 341 @Override 342 public boolean equalsDeep(Base other_) { 343 if (!super.equalsDeep(other_)) 344 return false; 345 if (!(other_ instanceof Binary)) 346 return false; 347 Binary o = (Binary) other_; 348 return compareDeep(contentType, o.contentType, true) && compareDeep(securityContext, o.securityContext, true) 349 && compareDeep(content, o.content, true); 350 } 351 352 @Override 353 public boolean equalsShallow(Base other_) { 354 if (!super.equalsShallow(other_)) 355 return false; 356 if (!(other_ instanceof Binary)) 357 return false; 358 Binary o = (Binary) other_; 359 return compareValues(contentType, o.contentType, true) && compareValues(content, o.content, true); 360 } 361 362 public boolean isEmpty() { 363 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(contentType, securityContext 364 , content); 365 } 366 367 @Override 368 public ResourceType getResourceType() { 369 return ResourceType.Binary; 370 } 371 372 /** 373 * Search parameter: <b>contenttype</b> 374 * <p> 375 * Description: <b>MimeType of the binary content</b><br> 376 * Type: <b>token</b><br> 377 * Path: <b>Binary.contentType</b><br> 378 * </p> 379 */ 380 @SearchParamDefinition(name="contenttype", path="Binary.contentType", description="MimeType of the binary content", type="token" ) 381 public static final String SP_CONTENTTYPE = "contenttype"; 382 /** 383 * <b>Fluent Client</b> search parameter constant for <b>contenttype</b> 384 * <p> 385 * Description: <b>MimeType of the binary content</b><br> 386 * Type: <b>token</b><br> 387 * Path: <b>Binary.contentType</b><br> 388 * </p> 389 */ 390 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTENTTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTENTTYPE); 391 392 393} 394