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 Mon, Apr 17, 2017 17:38-0400 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; 046/** 047 * A binary resource can contain any content, whether text, image, pdf, zip archive, etc. 048 */ 049@ResourceDef(name="Binary", profile="http://hl7.org/fhir/Profile/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 protected CodeType contentType; 058 059 /** 060 * Treat this binary as if it was this other resource for access control purposes. 061 */ 062 @Child(name = "securityContext", type = {Reference.class}, order=1, min=0, max=1, modifier=false, summary=true) 063 @Description(shortDefinition="Access Control Management", formalDefinition="Treat this binary as if it was this other resource for access control purposes." ) 064 protected Reference securityContext; 065 066 /** 067 * The actual object that is the target of the reference (Treat this binary as if it was this other resource for access control purposes.) 068 */ 069 protected Resource securityContextTarget; 070 071 /** 072 * The actual content, base64 encoded. 073 */ 074 @Child(name = "content", type = {Base64BinaryType.class}, order=2, min=1, max=1, modifier=false, summary=false) 075 @Description(shortDefinition="The actual content", formalDefinition="The actual content, base64 encoded." ) 076 protected Base64BinaryType content; 077 078 private static final long serialVersionUID = 1111991335L; 079 080 /** 081 * Constructor 082 */ 083 public Binary() { 084 super(); 085 } 086 087 /** 088 * Constructor 089 */ 090 public Binary(CodeType contentType, Base64BinaryType content) { 091 super(); 092 this.contentType = contentType; 093 this.content = content; 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} (Treat this binary as if it was this other resource for access control purposes.) 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} (Treat this binary as if it was this other resource for access control purposes.) 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. (Treat this binary as if it was this other resource for access control purposes.) 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. (Treat this binary as if it was this other resource for access control purposes.) 174 */ 175 public Binary setSecurityContextTarget(Resource value) { 176 this.securityContextTarget = value; 177 return this; 178 } 179 180 /** 181 * @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 182 */ 183 public Base64BinaryType getContentElement() { 184 if (this.content == null) 185 if (Configuration.errorOnAutoCreate()) 186 throw new Error("Attempt to auto-create Binary.content"); 187 else if (Configuration.doAutoCreate()) 188 this.content = new Base64BinaryType(); // bb 189 return this.content; 190 } 191 192 public boolean hasContentElement() { 193 return this.content != null && !this.content.isEmpty(); 194 } 195 196 public boolean hasContent() { 197 return this.content != null && !this.content.isEmpty(); 198 } 199 200 /** 201 * @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 202 */ 203 public Binary setContentElement(Base64BinaryType value) { 204 this.content = value; 205 return this; 206 } 207 208 /** 209 * @return The actual content, base64 encoded. 210 */ 211 public byte[] getContent() { 212 return this.content == null ? null : this.content.getValue(); 213 } 214 215 /** 216 * @param value The actual content, base64 encoded. 217 */ 218 public Binary setContent(byte[] value) { 219 if (this.content == null) 220 this.content = new Base64BinaryType(); 221 this.content.setValue(value); 222 return this; 223 } 224 225 protected void listChildren(List<Property> childrenList) { 226 super.listChildren(childrenList); 227 childrenList.add(new Property("contentType", "code", "MimeType of the binary content represented as a standard MimeType (BCP 13).", 0, java.lang.Integer.MAX_VALUE, contentType)); 228 childrenList.add(new Property("securityContext", "Reference(Any)", "Treat this binary as if it was this other resource for access control purposes.", 0, java.lang.Integer.MAX_VALUE, securityContext)); 229 childrenList.add(new Property("content", "base64Binary", "The actual content, base64 encoded.", 0, java.lang.Integer.MAX_VALUE, content)); 230 } 231 232 @Override 233 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 234 switch (hash) { 235 case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType 236 case -1622888881: /*securityContext*/ return this.securityContext == null ? new Base[0] : new Base[] {this.securityContext}; // Reference 237 case 951530617: /*content*/ return this.content == null ? new Base[0] : new Base[] {this.content}; // Base64BinaryType 238 default: return super.getProperty(hash, name, checkValid); 239 } 240 241 } 242 243 @Override 244 public Base setProperty(int hash, String name, Base value) throws FHIRException { 245 switch (hash) { 246 case -389131437: // contentType 247 this.contentType = castToCode(value); // CodeType 248 return value; 249 case -1622888881: // securityContext 250 this.securityContext = castToReference(value); // Reference 251 return value; 252 case 951530617: // content 253 this.content = castToBase64Binary(value); // Base64BinaryType 254 return value; 255 default: return super.setProperty(hash, name, value); 256 } 257 258 } 259 260 @Override 261 public Base setProperty(String name, Base value) throws FHIRException { 262 if (name.equals("contentType")) { 263 this.contentType = castToCode(value); // CodeType 264 } else if (name.equals("securityContext")) { 265 this.securityContext = castToReference(value); // Reference 266 } else if (name.equals("content")) { 267 this.content = castToBase64Binary(value); // Base64BinaryType 268 } else 269 return super.setProperty(name, value); 270 return value; 271 } 272 273 @Override 274 public Base makeProperty(int hash, String name) throws FHIRException { 275 switch (hash) { 276 case -389131437: return getContentTypeElement(); 277 case -1622888881: return getSecurityContext(); 278 case 951530617: return getContentElement(); 279 default: return super.makeProperty(hash, name); 280 } 281 282 } 283 284 @Override 285 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 286 switch (hash) { 287 case -389131437: /*contentType*/ return new String[] {"code"}; 288 case -1622888881: /*securityContext*/ return new String[] {"Reference"}; 289 case 951530617: /*content*/ return new String[] {"base64Binary"}; 290 default: return super.getTypesForProperty(hash, name); 291 } 292 293 } 294 295 @Override 296 public Base addChild(String name) throws FHIRException { 297 if (name.equals("contentType")) { 298 throw new FHIRException("Cannot call addChild on a primitive type Binary.contentType"); 299 } 300 else if (name.equals("securityContext")) { 301 this.securityContext = new Reference(); 302 return this.securityContext; 303 } 304 else if (name.equals("content")) { 305 throw new FHIRException("Cannot call addChild on a primitive type Binary.content"); 306 } 307 else 308 return super.addChild(name); 309 } 310 311 public String fhirType() { 312 return "Binary"; 313 314 } 315 316 public Binary copy() { 317 Binary dst = new Binary(); 318 copyValues(dst); 319 dst.contentType = contentType == null ? null : contentType.copy(); 320 dst.securityContext = securityContext == null ? null : securityContext.copy(); 321 dst.content = content == null ? null : content.copy(); 322 return dst; 323 } 324 325 protected Binary typedCopy() { 326 return copy(); 327 } 328 329 @Override 330 public boolean equalsDeep(Base other) { 331 if (!super.equalsDeep(other)) 332 return false; 333 if (!(other instanceof Binary)) 334 return false; 335 Binary o = (Binary) other; 336 return compareDeep(contentType, o.contentType, true) && compareDeep(securityContext, o.securityContext, true) 337 && compareDeep(content, o.content, true); 338 } 339 340 @Override 341 public boolean equalsShallow(Base other) { 342 if (!super.equalsShallow(other)) 343 return false; 344 if (!(other instanceof Binary)) 345 return false; 346 Binary o = (Binary) other; 347 return compareValues(contentType, o.contentType, true) && compareValues(content, o.content, true); 348 } 349 350 public boolean isEmpty() { 351 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(contentType, securityContext 352 , content); 353 } 354 355 @Override 356 public ResourceType getResourceType() { 357 return ResourceType.Binary; 358 } 359 360 /** 361 * Search parameter: <b>contenttype</b> 362 * <p> 363 * Description: <b>MimeType of the binary content</b><br> 364 * Type: <b>token</b><br> 365 * Path: <b>Binary.contentType</b><br> 366 * </p> 367 */ 368 @SearchParamDefinition(name="contenttype", path="Binary.contentType", description="MimeType of the binary content", type="token" ) 369 public static final String SP_CONTENTTYPE = "contenttype"; 370 /** 371 * <b>Fluent Client</b> search parameter constant for <b>contenttype</b> 372 * <p> 373 * Description: <b>MimeType of the binary content</b><br> 374 * Type: <b>token</b><br> 375 * Path: <b>Binary.contentType</b><br> 376 * </p> 377 */ 378 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTENTTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTENTTYPE); 379 380 381} 382