001package org.hl7.fhir.dstu2016may.model; 002 003 004 005 006/* 007 Copyright (c) 2011+, HL7, Inc. 008 All rights reserved. 009 010 Redistribution and use in source and binary forms, with or without modification, 011 are permitted provided that the following conditions are met: 012 013 * Redistributions of source code must retain the above copyright notice, this 014 list of conditions and the following disclaimer. 015 * Redistributions in binary form must reproduce the above copyright notice, 016 this list of conditions and the following disclaimer in the documentation 017 and/or other materials provided with the distribution. 018 * Neither the name of HL7 nor the names of its contributors may be used to 019 endorse or promote products derived from this software without specific 020 prior written permission. 021 022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 025 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 026 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 027 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 028 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 029 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 030 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 031 POSSIBILITY OF SUCH DAMAGE. 032 033*/ 034 035// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0 036import java.util.List; 037 038import org.hl7.fhir.exceptions.FHIRException; 039import org.hl7.fhir.instance.model.api.IBaseBinary; 040 041import ca.uhn.fhir.model.api.annotation.Child; 042import ca.uhn.fhir.model.api.annotation.Description; 043import ca.uhn.fhir.model.api.annotation.ResourceDef; 044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 045/** 046 * A binary resource can contain any content, whether text, image, pdf, zip archive, etc. 047 */ 048@ResourceDef(name="Binary", profile="http://hl7.org/fhir/Profile/Binary") 049public class Binary extends BaseBinary implements IBaseBinary { 050 051 /** 052 * MimeType of the binary content represented as a standard MimeType (BCP 13). 053 */ 054 @Child(name = "contentType", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true) 055 @Description(shortDefinition="MimeType of the binary content", formalDefinition="MimeType of the binary content represented as a standard MimeType (BCP 13)." ) 056 protected CodeType contentType; 057 058 /** 059 * The actual content, base64 encoded. 060 */ 061 @Child(name = "content", type = {Base64BinaryType.class}, order=1, min=1, max=1, modifier=false, summary=true) 062 @Description(shortDefinition="The actual content", formalDefinition="The actual content, base64 encoded." ) 063 protected Base64BinaryType content; 064 065 private static final long serialVersionUID = 974764407L; 066 067 /** 068 * Constructor 069 */ 070 public Binary() { 071 super(); 072 } 073 074 /** 075 * Constructor 076 */ 077 public Binary(CodeType contentType, Base64BinaryType content) { 078 super(); 079 this.contentType = contentType; 080 this.content = content; 081 } 082 083 /** 084 * @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 085 */ 086 public CodeType getContentTypeElement() { 087 if (this.contentType == null) 088 if (Configuration.errorOnAutoCreate()) 089 throw new Error("Attempt to auto-create Binary.contentType"); 090 else if (Configuration.doAutoCreate()) 091 this.contentType = new CodeType(); // bb 092 return this.contentType; 093 } 094 095 public boolean hasContentTypeElement() { 096 return this.contentType != null && !this.contentType.isEmpty(); 097 } 098 099 public boolean hasContentType() { 100 return this.contentType != null && !this.contentType.isEmpty(); 101 } 102 103 /** 104 * @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 105 */ 106 public Binary setContentTypeElement(CodeType value) { 107 this.contentType = value; 108 return this; 109 } 110 111 /** 112 * @return MimeType of the binary content represented as a standard MimeType (BCP 13). 113 */ 114 public String getContentType() { 115 return this.contentType == null ? null : this.contentType.getValue(); 116 } 117 118 /** 119 * @param value MimeType of the binary content represented as a standard MimeType (BCP 13). 120 */ 121 public Binary setContentType(String value) { 122 if (this.contentType == null) 123 this.contentType = new CodeType(); 124 this.contentType.setValue(value); 125 return this; 126 } 127 128 /** 129 * @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 130 */ 131 public Base64BinaryType getContentElement() { 132 if (this.content == null) 133 if (Configuration.errorOnAutoCreate()) 134 throw new Error("Attempt to auto-create Binary.content"); 135 else if (Configuration.doAutoCreate()) 136 this.content = new Base64BinaryType(); // bb 137 return this.content; 138 } 139 140 public boolean hasContentElement() { 141 return this.content != null && !this.content.isEmpty(); 142 } 143 144 public boolean hasContent() { 145 return this.content != null && !this.content.isEmpty(); 146 } 147 148 /** 149 * @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 150 */ 151 public Binary setContentElement(Base64BinaryType value) { 152 this.content = value; 153 return this; 154 } 155 156 /** 157 * @return The actual content, base64 encoded. 158 */ 159 public byte[] getContent() { 160 return this.content == null ? null : this.content.getValue(); 161 } 162 163 /** 164 * @param value The actual content, base64 encoded. 165 */ 166 public Binary setContent(byte[] value) { 167 if (this.content == null) 168 this.content = new Base64BinaryType(); 169 this.content.setValue(value); 170 return this; 171 } 172 173 protected void listChildren(List<Property> childrenList) { 174 super.listChildren(childrenList); 175 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)); 176 childrenList.add(new Property("content", "base64Binary", "The actual content, base64 encoded.", 0, java.lang.Integer.MAX_VALUE, content)); 177 } 178 179 @Override 180 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 181 switch (hash) { 182 case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType 183 case 951530617: /*content*/ return this.content == null ? new Base[0] : new Base[] {this.content}; // Base64BinaryType 184 default: return super.getProperty(hash, name, checkValid); 185 } 186 187 } 188 189 @Override 190 public void setProperty(int hash, String name, Base value) throws FHIRException { 191 switch (hash) { 192 case -389131437: // contentType 193 this.contentType = castToCode(value); // CodeType 194 break; 195 case 951530617: // content 196 this.content = castToBase64Binary(value); // Base64BinaryType 197 break; 198 default: super.setProperty(hash, name, value); 199 } 200 201 } 202 203 @Override 204 public void setProperty(String name, Base value) throws FHIRException { 205 if (name.equals("contentType")) 206 this.contentType = castToCode(value); // CodeType 207 else if (name.equals("content")) 208 this.content = castToBase64Binary(value); // Base64BinaryType 209 else 210 super.setProperty(name, value); 211 } 212 213 @Override 214 public Base makeProperty(int hash, String name) throws FHIRException { 215 switch (hash) { 216 case -389131437: throw new FHIRException("Cannot make property contentType as it is not a complex type"); // CodeType 217 case 951530617: throw new FHIRException("Cannot make property content as it is not a complex type"); // Base64BinaryType 218 default: return super.makeProperty(hash, name); 219 } 220 221 } 222 223 @Override 224 public Base addChild(String name) throws FHIRException { 225 if (name.equals("contentType")) { 226 throw new FHIRException("Cannot call addChild on a primitive type Binary.contentType"); 227 } 228 else if (name.equals("content")) { 229 throw new FHIRException("Cannot call addChild on a primitive type Binary.content"); 230 } 231 else 232 return super.addChild(name); 233 } 234 235 public String fhirType() { 236 return "Binary"; 237 238 } 239 240 public Binary copy() { 241 Binary dst = new Binary(); 242 copyValues(dst); 243 dst.contentType = contentType == null ? null : contentType.copy(); 244 dst.content = content == null ? null : content.copy(); 245 return dst; 246 } 247 248 protected Binary typedCopy() { 249 return copy(); 250 } 251 252 @Override 253 public boolean equalsDeep(Base other) { 254 if (!super.equalsDeep(other)) 255 return false; 256 if (!(other instanceof Binary)) 257 return false; 258 Binary o = (Binary) other; 259 return compareDeep(contentType, o.contentType, true) && compareDeep(content, o.content, true); 260 } 261 262 @Override 263 public boolean equalsShallow(Base other) { 264 if (!super.equalsShallow(other)) 265 return false; 266 if (!(other instanceof Binary)) 267 return false; 268 Binary o = (Binary) other; 269 return compareValues(contentType, o.contentType, true) && compareValues(content, o.content, true); 270 } 271 272 public boolean isEmpty() { 273 return super.isEmpty() && (contentType == null || contentType.isEmpty()) && (content == null || content.isEmpty()) 274 ; 275 } 276 277 @Override 278 public ResourceType getResourceType() { 279 return ResourceType.Binary; 280 } 281 282 /** 283 * Search parameter: <b>contenttype</b> 284 * <p> 285 * Description: <b>MimeType of the binary content</b><br> 286 * Type: <b>token</b><br> 287 * Path: <b>Binary.contentType</b><br> 288 * </p> 289 */ 290 @SearchParamDefinition(name="contenttype", path="Binary.contentType", description="MimeType of the binary content", type="token" ) 291 public static final String SP_CONTENTTYPE = "contenttype"; 292 /** 293 * <b>Fluent Client</b> search parameter constant for <b>contenttype</b> 294 * <p> 295 * Description: <b>MimeType of the binary content</b><br> 296 * Type: <b>token</b><br> 297 * Path: <b>Binary.contentType</b><br> 298 * </p> 299 */ 300 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTENTTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTENTTYPE); 301 302 303}