001package org.hl7.fhir.instance.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 Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 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.*; 039/** 040 * A binary resource can contain any content, whether text, image, pdf, zip archive, etc. 041 */ 042@ResourceDef(name="Binary", profile="http://hl7.org/fhir/Profile/Binary") 043public class Binary extends BaseBinary implements IBaseBinary { 044 045 /** 046 * MimeType of the binary content represented as a standard MimeType (BCP 13). 047 */ 048 @Child(name = "contentType", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true) 049 @Description(shortDefinition="MimeType of the binary content", formalDefinition="MimeType of the binary content represented as a standard MimeType (BCP 13)." ) 050 protected CodeType contentType; 051 052 /** 053 * The actual content, base64 encoded. 054 */ 055 @Child(name = "content", type = {Base64BinaryType.class}, order=1, min=1, max=1, modifier=false, summary=true) 056 @Description(shortDefinition="The actual content", formalDefinition="The actual content, base64 encoded." ) 057 protected Base64BinaryType content; 058 059 private static final long serialVersionUID = 974764407L; 060 061 /* 062 * Constructor 063 */ 064 public Binary() { 065 super(); 066 } 067 068 /* 069 * Constructor 070 */ 071 public Binary(CodeType contentType, Base64BinaryType content) { 072 super(); 073 this.contentType = contentType; 074 this.content = content; 075 } 076 077 /** 078 * @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 079 */ 080 public CodeType getContentTypeElement() { 081 if (this.contentType == null) 082 if (Configuration.errorOnAutoCreate()) 083 throw new Error("Attempt to auto-create Binary.contentType"); 084 else if (Configuration.doAutoCreate()) 085 this.contentType = new CodeType(); // bb 086 return this.contentType; 087 } 088 089 public boolean hasContentTypeElement() { 090 return this.contentType != null && !this.contentType.isEmpty(); 091 } 092 093 public boolean hasContentType() { 094 return this.contentType != null && !this.contentType.isEmpty(); 095 } 096 097 /** 098 * @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 099 */ 100 public Binary setContentTypeElement(CodeType value) { 101 this.contentType = value; 102 return this; 103 } 104 105 /** 106 * @return MimeType of the binary content represented as a standard MimeType (BCP 13). 107 */ 108 public String getContentType() { 109 return this.contentType == null ? null : this.contentType.getValue(); 110 } 111 112 /** 113 * @param value MimeType of the binary content represented as a standard MimeType (BCP 13). 114 */ 115 public Binary setContentType(String value) { 116 if (this.contentType == null) 117 this.contentType = new CodeType(); 118 this.contentType.setValue(value); 119 return this; 120 } 121 122 /** 123 * @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 124 */ 125 public Base64BinaryType getContentElement() { 126 if (this.content == null) 127 if (Configuration.errorOnAutoCreate()) 128 throw new Error("Attempt to auto-create Binary.content"); 129 else if (Configuration.doAutoCreate()) 130 this.content = new Base64BinaryType(); // bb 131 return this.content; 132 } 133 134 public boolean hasContentElement() { 135 return this.content != null && !this.content.isEmpty(); 136 } 137 138 public boolean hasContent() { 139 return this.content != null && !this.content.isEmpty(); 140 } 141 142 /** 143 * @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 144 */ 145 public Binary setContentElement(Base64BinaryType value) { 146 this.content = value; 147 return this; 148 } 149 150 /** 151 * @return The actual content, base64 encoded. 152 */ 153 public byte[] getContent() { 154 return this.content == null ? null : this.content.getValue(); 155 } 156 157 /** 158 * @param value The actual content, base64 encoded. 159 */ 160 public Binary setContent(byte[] value) { 161 if (this.content == null) 162 this.content = new Base64BinaryType(); 163 this.content.setValue(value); 164 return this; 165 } 166 167 protected void listChildren(List<Property> childrenList) { 168 super.listChildren(childrenList); 169 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)); 170 childrenList.add(new Property("content", "base64Binary", "The actual content, base64 encoded.", 0, java.lang.Integer.MAX_VALUE, content)); 171 } 172 173 @Override 174 public void setProperty(String name, Base value) throws FHIRException { 175 if (name.equals("contentType")) 176 this.contentType = castToCode(value); // CodeType 177 else if (name.equals("content")) 178 this.content = castToBase64Binary(value); // Base64BinaryType 179 else 180 super.setProperty(name, value); 181 } 182 183 @Override 184 public Base addChild(String name) throws FHIRException { 185 if (name.equals("contentType")) { 186 throw new FHIRException("Cannot call addChild on a primitive type Binary.contentType"); 187 } 188 else if (name.equals("content")) { 189 throw new FHIRException("Cannot call addChild on a primitive type Binary.content"); 190 } 191 else 192 return super.addChild(name); 193 } 194 195 public String fhirType() { 196 return "Binary"; 197 198 } 199 200 public Binary copy() { 201 Binary dst = new Binary(); 202 copyValues(dst); 203 dst.contentType = contentType == null ? null : contentType.copy(); 204 dst.content = content == null ? null : content.copy(); 205 return dst; 206 } 207 208 protected Binary typedCopy() { 209 return copy(); 210 } 211 212 @Override 213 public boolean equalsDeep(Base other) { 214 if (!super.equalsDeep(other)) 215 return false; 216 if (!(other instanceof Binary)) 217 return false; 218 Binary o = (Binary) other; 219 return compareDeep(contentType, o.contentType, true) && compareDeep(content, o.content, true); 220 } 221 222 @Override 223 public boolean equalsShallow(Base other) { 224 if (!super.equalsShallow(other)) 225 return false; 226 if (!(other instanceof Binary)) 227 return false; 228 Binary o = (Binary) other; 229 return compareValues(contentType, o.contentType, true) && compareValues(content, o.content, true); 230 } 231 232 public boolean isEmpty() { 233 return super.isEmpty() && (contentType == null || contentType.isEmpty()) && (content == null || content.isEmpty()) 234 ; 235 } 236 237 @Override 238 public ResourceType getResourceType() { 239 return ResourceType.Binary; 240 } 241 242 @SearchParamDefinition(name="contenttype", path="Binary.contentType", description="MimeType of the binary content", type="token" ) 243 public static final String SP_CONTENTTYPE = "contenttype"; 244 245} 246