001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0 033import java.util.List; 034 035import org.hl7.fhir.exceptions.FHIRException; 036import org.hl7.fhir.instance.model.api.IBaseBinary; 037 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.Description; 040import ca.uhn.fhir.model.api.annotation.ResourceDef; 041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 042/** 043 * A binary resource can contain any content, whether text, image, pdf, zip archive, etc. 044 */ 045@ResourceDef(name="Binary", profile="http://hl7.org/fhir/Profile/Binary") 046public class Binary extends BaseBinary implements IBaseBinary { 047 048 /** 049 * MimeType of the binary content represented as a standard MimeType (BCP 13). 050 */ 051 @Child(name = "contentType", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true) 052 @Description(shortDefinition="MimeType of the binary content", formalDefinition="MimeType of the binary content represented as a standard MimeType (BCP 13)." ) 053 protected CodeType contentType; 054 055 /** 056 * The actual content, base64 encoded. 057 */ 058 @Child(name = "content", type = {Base64BinaryType.class}, order=1, min=1, max=1, modifier=false, summary=true) 059 @Description(shortDefinition="The actual content", formalDefinition="The actual content, base64 encoded." ) 060 protected Base64BinaryType content; 061 062 private static final long serialVersionUID = 974764407L; 063 064 /** 065 * Constructor 066 */ 067 public Binary() { 068 super(); 069 } 070 071 /** 072 * Constructor 073 */ 074 public Binary(CodeType contentType, Base64BinaryType content) { 075 super(); 076 this.contentType = contentType; 077 this.content = content; 078 } 079 080 /** 081 * @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 082 */ 083 public CodeType getContentTypeElement() { 084 if (this.contentType == null) 085 if (Configuration.errorOnAutoCreate()) 086 throw new Error("Attempt to auto-create Binary.contentType"); 087 else if (Configuration.doAutoCreate()) 088 this.contentType = new CodeType(); // bb 089 return this.contentType; 090 } 091 092 public boolean hasContentTypeElement() { 093 return this.contentType != null && !this.contentType.isEmpty(); 094 } 095 096 public boolean hasContentType() { 097 return this.contentType != null && !this.contentType.isEmpty(); 098 } 099 100 /** 101 * @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 102 */ 103 public Binary setContentTypeElement(CodeType value) { 104 this.contentType = value; 105 return this; 106 } 107 108 /** 109 * @return MimeType of the binary content represented as a standard MimeType (BCP 13). 110 */ 111 public String getContentType() { 112 return this.contentType == null ? null : this.contentType.getValue(); 113 } 114 115 /** 116 * @param value MimeType of the binary content represented as a standard MimeType (BCP 13). 117 */ 118 public Binary setContentType(String value) { 119 if (this.contentType == null) 120 this.contentType = new CodeType(); 121 this.contentType.setValue(value); 122 return this; 123 } 124 125 /** 126 * @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 127 */ 128 public Base64BinaryType getContentElement() { 129 if (this.content == null) 130 if (Configuration.errorOnAutoCreate()) 131 throw new Error("Attempt to auto-create Binary.content"); 132 else if (Configuration.doAutoCreate()) 133 this.content = new Base64BinaryType(); // bb 134 return this.content; 135 } 136 137 public boolean hasContentElement() { 138 return this.content != null && !this.content.isEmpty(); 139 } 140 141 public boolean hasContent() { 142 return this.content != null && !this.content.isEmpty(); 143 } 144 145 /** 146 * @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 147 */ 148 public Binary setContentElement(Base64BinaryType value) { 149 this.content = value; 150 return this; 151 } 152 153 /** 154 * @return The actual content, base64 encoded. 155 */ 156 public byte[] getContent() { 157 return this.content == null ? null : this.content.getValue(); 158 } 159 160 /** 161 * @param value The actual content, base64 encoded. 162 */ 163 public Binary setContent(byte[] value) { 164 if (this.content == null) 165 this.content = new Base64BinaryType(); 166 this.content.setValue(value); 167 return this; 168 } 169 170 protected void listChildren(List<Property> childrenList) { 171 super.listChildren(childrenList); 172 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)); 173 childrenList.add(new Property("content", "base64Binary", "The actual content, base64 encoded.", 0, java.lang.Integer.MAX_VALUE, content)); 174 } 175 176 @Override 177 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 178 switch (hash) { 179 case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType 180 case 951530617: /*content*/ return this.content == null ? new Base[0] : new Base[] {this.content}; // Base64BinaryType 181 default: return super.getProperty(hash, name, checkValid); 182 } 183 184 } 185 186 @Override 187 public void setProperty(int hash, String name, Base value) throws FHIRException { 188 switch (hash) { 189 case -389131437: // contentType 190 this.contentType = castToCode(value); // CodeType 191 break; 192 case 951530617: // content 193 this.content = castToBase64Binary(value); // Base64BinaryType 194 break; 195 default: super.setProperty(hash, name, value); 196 } 197 198 } 199 200 @Override 201 public void setProperty(String name, Base value) throws FHIRException { 202 if (name.equals("contentType")) 203 this.contentType = castToCode(value); // CodeType 204 else if (name.equals("content")) 205 this.content = castToBase64Binary(value); // Base64BinaryType 206 else 207 super.setProperty(name, value); 208 } 209 210 @Override 211 public Base makeProperty(int hash, String name) throws FHIRException { 212 switch (hash) { 213 case -389131437: throw new FHIRException("Cannot make property contentType as it is not a complex type"); // CodeType 214 case 951530617: throw new FHIRException("Cannot make property content as it is not a complex type"); // Base64BinaryType 215 default: return super.makeProperty(hash, name); 216 } 217 218 } 219 220 @Override 221 public Base addChild(String name) throws FHIRException { 222 if (name.equals("contentType")) { 223 throw new FHIRException("Cannot call addChild on a primitive type Binary.contentType"); 224 } 225 else if (name.equals("content")) { 226 throw new FHIRException("Cannot call addChild on a primitive type Binary.content"); 227 } 228 else 229 return super.addChild(name); 230 } 231 232 public String fhirType() { 233 return "Binary"; 234 235 } 236 237 public Binary copy() { 238 Binary dst = new Binary(); 239 copyValues(dst); 240 dst.contentType = contentType == null ? null : contentType.copy(); 241 dst.content = content == null ? null : content.copy(); 242 return dst; 243 } 244 245 protected Binary typedCopy() { 246 return copy(); 247 } 248 249 @Override 250 public boolean equalsDeep(Base other) { 251 if (!super.equalsDeep(other)) 252 return false; 253 if (!(other instanceof Binary)) 254 return false; 255 Binary o = (Binary) other; 256 return compareDeep(contentType, o.contentType, true) && compareDeep(content, o.content, true); 257 } 258 259 @Override 260 public boolean equalsShallow(Base other) { 261 if (!super.equalsShallow(other)) 262 return false; 263 if (!(other instanceof Binary)) 264 return false; 265 Binary o = (Binary) other; 266 return compareValues(contentType, o.contentType, true) && compareValues(content, o.content, true); 267 } 268 269 public boolean isEmpty() { 270 return super.isEmpty() && (contentType == null || contentType.isEmpty()) && (content == null || content.isEmpty()) 271 ; 272 } 273 274 @Override 275 public ResourceType getResourceType() { 276 return ResourceType.Binary; 277 } 278 279 /** 280 * Search parameter: <b>contenttype</b> 281 * <p> 282 * Description: <b>MimeType of the binary content</b><br> 283 * Type: <b>token</b><br> 284 * Path: <b>Binary.contentType</b><br> 285 * </p> 286 */ 287 @SearchParamDefinition(name="contenttype", path="Binary.contentType", description="MimeType of the binary content", type="token" ) 288 public static final String SP_CONTENTTYPE = "contenttype"; 289 /** 290 * <b>Fluent Client</b> search parameter constant for <b>contenttype</b> 291 * <p> 292 * Description: <b>MimeType of the binary content</b><br> 293 * Type: <b>token</b><br> 294 * Path: <b>Binary.contentType</b><br> 295 * </p> 296 */ 297 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTENTTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTENTTYPE); 298 299 300} 301