001package org.hl7.fhir.r4.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r4
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/*
024  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
053import java.util.Date;
054import java.util.List;
055
056import org.hl7.fhir.exceptions.FHIRException;
057import org.hl7.fhir.instance.model.api.ICompositeType;
058import org.hl7.fhir.utilities.Utilities;
059
060import ca.uhn.fhir.model.api.annotation.Child;
061import ca.uhn.fhir.model.api.annotation.DatatypeDef;
062import ca.uhn.fhir.model.api.annotation.Description;
063/**
064 * For referring to data content defined in other formats.
065 */
066@DatatypeDef(name="Attachment")
067public class Attachment extends Type implements ICompositeType {
068
069    /**
070     * Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
071     */
072    @Child(name = "contentType", type = {CodeType.class}, order=0, min=0, max=1, modifier=false, summary=true)
073    @Description(shortDefinition="Mime type of the content, with charset etc.", formalDefinition="Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate." )
074    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/mimetypes")
075    protected CodeType contentType;
076
077    /**
078     * The human language of the content. The value can be any valid value according to BCP 47.
079     */
080    @Child(name = "language", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
081    @Description(shortDefinition="Human language of the content (BCP-47)", formalDefinition="The human language of the content. The value can be any valid value according to BCP 47." )
082    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/languages")
083    protected CodeType language;
084
085    /**
086     * The actual data of the attachment - a sequence of bytes, base64 encoded.
087     */
088    @Child(name = "data", type = {Base64BinaryType.class}, order=2, min=0, max=1, modifier=false, summary=false)
089    @Description(shortDefinition="Data inline, base64ed", formalDefinition="The actual data of the attachment - a sequence of bytes, base64 encoded." )
090    protected Base64BinaryType data;
091
092    /**
093     * A location where the data can be accessed.
094     */
095    @Child(name = "url", type = {UrlType.class}, order=3, min=0, max=1, modifier=false, summary=true)
096    @Description(shortDefinition="Uri where the data can be found", formalDefinition="A location where the data can be accessed." )
097    protected UrlType url;
098
099    /**
100     * The number of bytes of data that make up this attachment (before base64 encoding, if that is done).
101     */
102    @Child(name = "size", type = {UnsignedIntType.class}, order=4, min=0, max=1, modifier=false, summary=true)
103    @Description(shortDefinition="Number of bytes of content (if url provided)", formalDefinition="The number of bytes of data that make up this attachment (before base64 encoding, if that is done)." )
104    protected UnsignedIntType size;
105
106    /**
107     * The calculated hash of the data using SHA-1. Represented using base64.
108     */
109    @Child(name = "hash", type = {Base64BinaryType.class}, order=5, min=0, max=1, modifier=false, summary=true)
110    @Description(shortDefinition="Hash of the data (sha-1, base64ed)", formalDefinition="The calculated hash of the data using SHA-1. Represented using base64." )
111    protected Base64BinaryType hash;
112
113    /**
114     * A label or set of text to display in place of the data.
115     */
116    @Child(name = "title", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
117    @Description(shortDefinition="Label to display in place of the data", formalDefinition="A label or set of text to display in place of the data." )
118    protected StringType title;
119
120    /**
121     * The date that the attachment was first created.
122     */
123    @Child(name = "creation", type = {DateTimeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
124    @Description(shortDefinition="Date attachment was first created", formalDefinition="The date that the attachment was first created." )
125    protected DateTimeType creation;
126
127    private static final long serialVersionUID = -564352571L;
128
129  /**
130   * Constructor
131   */
132    public Attachment() {
133      super();
134    }
135
136    /**
137     * @return {@link #contentType} (Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value
138     */
139    public CodeType getContentTypeElement() { 
140      if (this.contentType == null)
141        if (Configuration.errorOnAutoCreate())
142          throw new Error("Attempt to auto-create Attachment.contentType");
143        else if (Configuration.doAutoCreate())
144          this.contentType = new CodeType(); // bb
145      return this.contentType;
146    }
147
148    public boolean hasContentTypeElement() { 
149      return this.contentType != null && !this.contentType.isEmpty();
150    }
151
152    public boolean hasContentType() { 
153      return this.contentType != null && !this.contentType.isEmpty();
154    }
155
156    /**
157     * @param value {@link #contentType} (Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value
158     */
159    public Attachment setContentTypeElement(CodeType value) { 
160      this.contentType = value;
161      return this;
162    }
163
164    /**
165     * @return Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
166     */
167    public String getContentType() { 
168      return this.contentType == null ? null : this.contentType.getValue();
169    }
170
171    /**
172     * @param value Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
173     */
174    public Attachment setContentType(String value) { 
175      if (Utilities.noString(value))
176        this.contentType = null;
177      else {
178        if (this.contentType == null)
179          this.contentType = new CodeType();
180        this.contentType.setValue(value);
181      }
182      return this;
183    }
184
185    /**
186     * @return {@link #language} (The human language of the content. The value can be any valid value according to BCP 47.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
187     */
188    public CodeType getLanguageElement() { 
189      if (this.language == null)
190        if (Configuration.errorOnAutoCreate())
191          throw new Error("Attempt to auto-create Attachment.language");
192        else if (Configuration.doAutoCreate())
193          this.language = new CodeType(); // bb
194      return this.language;
195    }
196
197    public boolean hasLanguageElement() { 
198      return this.language != null && !this.language.isEmpty();
199    }
200
201    public boolean hasLanguage() { 
202      return this.language != null && !this.language.isEmpty();
203    }
204
205    /**
206     * @param value {@link #language} (The human language of the content. The value can be any valid value according to BCP 47.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
207     */
208    public Attachment setLanguageElement(CodeType value) { 
209      this.language = value;
210      return this;
211    }
212
213    /**
214     * @return The human language of the content. The value can be any valid value according to BCP 47.
215     */
216    public String getLanguage() { 
217      return this.language == null ? null : this.language.getValue();
218    }
219
220    /**
221     * @param value The human language of the content. The value can be any valid value according to BCP 47.
222     */
223    public Attachment setLanguage(String value) { 
224      if (Utilities.noString(value))
225        this.language = null;
226      else {
227        if (this.language == null)
228          this.language = new CodeType();
229        this.language.setValue(value);
230      }
231      return this;
232    }
233
234    /**
235     * @return {@link #data} (The actual data of the attachment - a sequence of bytes, base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value
236     */
237    public Base64BinaryType getDataElement() { 
238      if (this.data == null)
239        if (Configuration.errorOnAutoCreate())
240          throw new Error("Attempt to auto-create Attachment.data");
241        else if (Configuration.doAutoCreate())
242          this.data = new Base64BinaryType(); // bb
243      return this.data;
244    }
245
246    public boolean hasDataElement() { 
247      return this.data != null && !this.data.isEmpty();
248    }
249
250    public boolean hasData() { 
251      return this.data != null && !this.data.isEmpty();
252    }
253
254    /**
255     * @param value {@link #data} (The actual data of the attachment - a sequence of bytes, base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value
256     */
257    public Attachment setDataElement(Base64BinaryType value) { 
258      this.data = value;
259      return this;
260    }
261
262    /**
263     * @return The actual data of the attachment - a sequence of bytes, base64 encoded.
264     */
265    public byte[] getData() { 
266      return this.data == null ? null : this.data.getValue();
267    }
268
269    /**
270     * @param value The actual data of the attachment - a sequence of bytes, base64 encoded.
271     */
272    public Attachment setData(byte[] value) { 
273      if (value == null)
274        this.data = null;
275      else {
276        if (this.data == null)
277          this.data = new Base64BinaryType();
278        this.data.setValue(value);
279      }
280      return this;
281    }
282
283    /**
284     * @return {@link #url} (A location where the data can be accessed.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
285     */
286    public UrlType getUrlElement() { 
287      if (this.url == null)
288        if (Configuration.errorOnAutoCreate())
289          throw new Error("Attempt to auto-create Attachment.url");
290        else if (Configuration.doAutoCreate())
291          this.url = new UrlType(); // bb
292      return this.url;
293    }
294
295    public boolean hasUrlElement() { 
296      return this.url != null && !this.url.isEmpty();
297    }
298
299    public boolean hasUrl() { 
300      return this.url != null && !this.url.isEmpty();
301    }
302
303    /**
304     * @param value {@link #url} (A location where the data can be accessed.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
305     */
306    public Attachment setUrlElement(UrlType value) { 
307      this.url = value;
308      return this;
309    }
310
311    /**
312     * @return A location where the data can be accessed.
313     */
314    public String getUrl() { 
315      return this.url == null ? null : this.url.getValue();
316    }
317
318    /**
319     * @param value A location where the data can be accessed.
320     */
321    public Attachment setUrl(String value) { 
322      if (Utilities.noString(value))
323        this.url = null;
324      else {
325        if (this.url == null)
326          this.url = new UrlType();
327        this.url.setValue(value);
328      }
329      return this;
330    }
331
332    /**
333     * @return {@link #size} (The number of bytes of data that make up this attachment (before base64 encoding, if that is done).). This is the underlying object with id, value and extensions. The accessor "getSize" gives direct access to the value
334     */
335    public UnsignedIntType getSizeElement() { 
336      if (this.size == null)
337        if (Configuration.errorOnAutoCreate())
338          throw new Error("Attempt to auto-create Attachment.size");
339        else if (Configuration.doAutoCreate())
340          this.size = new UnsignedIntType(); // bb
341      return this.size;
342    }
343
344    public boolean hasSizeElement() { 
345      return this.size != null && !this.size.isEmpty();
346    }
347
348    public boolean hasSize() { 
349      return this.size != null && !this.size.isEmpty();
350    }
351
352    /**
353     * @param value {@link #size} (The number of bytes of data that make up this attachment (before base64 encoding, if that is done).). This is the underlying object with id, value and extensions. The accessor "getSize" gives direct access to the value
354     */
355    public Attachment setSizeElement(UnsignedIntType value) { 
356      this.size = value;
357      return this;
358    }
359
360    /**
361     * @return The number of bytes of data that make up this attachment (before base64 encoding, if that is done).
362     */
363    public int getSize() { 
364      return this.size == null || this.size.isEmpty() ? 0 : this.size.getValue();
365    }
366
367    /**
368     * @param value The number of bytes of data that make up this attachment (before base64 encoding, if that is done).
369     */
370    public Attachment setSize(int value) { 
371        if (this.size == null)
372          this.size = new UnsignedIntType();
373        this.size.setValue(value);
374      return this;
375    }
376
377    /**
378     * @return {@link #hash} (The calculated hash of the data using SHA-1. Represented using base64.). This is the underlying object with id, value and extensions. The accessor "getHash" gives direct access to the value
379     */
380    public Base64BinaryType getHashElement() { 
381      if (this.hash == null)
382        if (Configuration.errorOnAutoCreate())
383          throw new Error("Attempt to auto-create Attachment.hash");
384        else if (Configuration.doAutoCreate())
385          this.hash = new Base64BinaryType(); // bb
386      return this.hash;
387    }
388
389    public boolean hasHashElement() { 
390      return this.hash != null && !this.hash.isEmpty();
391    }
392
393    public boolean hasHash() { 
394      return this.hash != null && !this.hash.isEmpty();
395    }
396
397    /**
398     * @param value {@link #hash} (The calculated hash of the data using SHA-1. Represented using base64.). This is the underlying object with id, value and extensions. The accessor "getHash" gives direct access to the value
399     */
400    public Attachment setHashElement(Base64BinaryType value) { 
401      this.hash = value;
402      return this;
403    }
404
405    /**
406     * @return The calculated hash of the data using SHA-1. Represented using base64.
407     */
408    public byte[] getHash() { 
409      return this.hash == null ? null : this.hash.getValue();
410    }
411
412    /**
413     * @param value The calculated hash of the data using SHA-1. Represented using base64.
414     */
415    public Attachment setHash(byte[] value) { 
416      if (value == null)
417        this.hash = null;
418      else {
419        if (this.hash == null)
420          this.hash = new Base64BinaryType();
421        this.hash.setValue(value);
422      }
423      return this;
424    }
425
426    /**
427     * @return {@link #title} (A label or set of text to display in place of the data.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
428     */
429    public StringType getTitleElement() { 
430      if (this.title == null)
431        if (Configuration.errorOnAutoCreate())
432          throw new Error("Attempt to auto-create Attachment.title");
433        else if (Configuration.doAutoCreate())
434          this.title = new StringType(); // bb
435      return this.title;
436    }
437
438    public boolean hasTitleElement() { 
439      return this.title != null && !this.title.isEmpty();
440    }
441
442    public boolean hasTitle() { 
443      return this.title != null && !this.title.isEmpty();
444    }
445
446    /**
447     * @param value {@link #title} (A label or set of text to display in place of the data.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
448     */
449    public Attachment setTitleElement(StringType value) { 
450      this.title = value;
451      return this;
452    }
453
454    /**
455     * @return A label or set of text to display in place of the data.
456     */
457    public String getTitle() { 
458      return this.title == null ? null : this.title.getValue();
459    }
460
461    /**
462     * @param value A label or set of text to display in place of the data.
463     */
464    public Attachment setTitle(String value) { 
465      if (Utilities.noString(value))
466        this.title = null;
467      else {
468        if (this.title == null)
469          this.title = new StringType();
470        this.title.setValue(value);
471      }
472      return this;
473    }
474
475    /**
476     * @return {@link #creation} (The date that the attachment was first created.). This is the underlying object with id, value and extensions. The accessor "getCreation" gives direct access to the value
477     */
478    public DateTimeType getCreationElement() { 
479      if (this.creation == null)
480        if (Configuration.errorOnAutoCreate())
481          throw new Error("Attempt to auto-create Attachment.creation");
482        else if (Configuration.doAutoCreate())
483          this.creation = new DateTimeType(); // bb
484      return this.creation;
485    }
486
487    public boolean hasCreationElement() { 
488      return this.creation != null && !this.creation.isEmpty();
489    }
490
491    public boolean hasCreation() { 
492      return this.creation != null && !this.creation.isEmpty();
493    }
494
495    /**
496     * @param value {@link #creation} (The date that the attachment was first created.). This is the underlying object with id, value and extensions. The accessor "getCreation" gives direct access to the value
497     */
498    public Attachment setCreationElement(DateTimeType value) { 
499      this.creation = value;
500      return this;
501    }
502
503    /**
504     * @return The date that the attachment was first created.
505     */
506    public Date getCreation() { 
507      return this.creation == null ? null : this.creation.getValue();
508    }
509
510    /**
511     * @param value The date that the attachment was first created.
512     */
513    public Attachment setCreation(Date value) { 
514      if (value == null)
515        this.creation = null;
516      else {
517        if (this.creation == null)
518          this.creation = new DateTimeType();
519        this.creation.setValue(value);
520      }
521      return this;
522    }
523
524      protected void listChildren(List<Property> children) {
525        super.listChildren(children);
526        children.add(new Property("contentType", "code", "Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.", 0, 1, contentType));
527        children.add(new Property("language", "code", "The human language of the content. The value can be any valid value according to BCP 47.", 0, 1, language));
528        children.add(new Property("data", "base64Binary", "The actual data of the attachment - a sequence of bytes, base64 encoded.", 0, 1, data));
529        children.add(new Property("url", "url", "A location where the data can be accessed.", 0, 1, url));
530        children.add(new Property("size", "unsignedInt", "The number of bytes of data that make up this attachment (before base64 encoding, if that is done).", 0, 1, size));
531        children.add(new Property("hash", "base64Binary", "The calculated hash of the data using SHA-1. Represented using base64.", 0, 1, hash));
532        children.add(new Property("title", "string", "A label or set of text to display in place of the data.", 0, 1, title));
533        children.add(new Property("creation", "dateTime", "The date that the attachment was first created.", 0, 1, creation));
534      }
535
536      @Override
537      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
538        switch (_hash) {
539        case -389131437: /*contentType*/  return new Property("contentType", "code", "Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.", 0, 1, contentType);
540        case -1613589672: /*language*/  return new Property("language", "code", "The human language of the content. The value can be any valid value according to BCP 47.", 0, 1, language);
541        case 3076010: /*data*/  return new Property("data", "base64Binary", "The actual data of the attachment - a sequence of bytes, base64 encoded.", 0, 1, data);
542        case 116079: /*url*/  return new Property("url", "url", "A location where the data can be accessed.", 0, 1, url);
543        case 3530753: /*size*/  return new Property("size", "unsignedInt", "The number of bytes of data that make up this attachment (before base64 encoding, if that is done).", 0, 1, size);
544        case 3195150: /*hash*/  return new Property("hash", "base64Binary", "The calculated hash of the data using SHA-1. Represented using base64.", 0, 1, hash);
545        case 110371416: /*title*/  return new Property("title", "string", "A label or set of text to display in place of the data.", 0, 1, title);
546        case 1820421855: /*creation*/  return new Property("creation", "dateTime", "The date that the attachment was first created.", 0, 1, creation);
547        default: return super.getNamedProperty(_hash, _name, _checkValid);
548        }
549
550      }
551
552      @Override
553      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
554        switch (hash) {
555        case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType
556        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType
557        case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // Base64BinaryType
558        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UrlType
559        case 3530753: /*size*/ return this.size == null ? new Base[0] : new Base[] {this.size}; // UnsignedIntType
560        case 3195150: /*hash*/ return this.hash == null ? new Base[0] : new Base[] {this.hash}; // Base64BinaryType
561        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
562        case 1820421855: /*creation*/ return this.creation == null ? new Base[0] : new Base[] {this.creation}; // DateTimeType
563        default: return super.getProperty(hash, name, checkValid);
564        }
565
566      }
567
568      @Override
569      public Base setProperty(int hash, String name, Base value) throws FHIRException {
570        switch (hash) {
571        case -389131437: // contentType
572          this.contentType = castToCode(value); // CodeType
573          return value;
574        case -1613589672: // language
575          this.language = castToCode(value); // CodeType
576          return value;
577        case 3076010: // data
578          this.data = castToBase64Binary(value); // Base64BinaryType
579          return value;
580        case 116079: // url
581          this.url = castToUrl(value); // UrlType
582          return value;
583        case 3530753: // size
584          this.size = castToUnsignedInt(value); // UnsignedIntType
585          return value;
586        case 3195150: // hash
587          this.hash = castToBase64Binary(value); // Base64BinaryType
588          return value;
589        case 110371416: // title
590          this.title = castToString(value); // StringType
591          return value;
592        case 1820421855: // creation
593          this.creation = castToDateTime(value); // DateTimeType
594          return value;
595        default: return super.setProperty(hash, name, value);
596        }
597
598      }
599
600      @Override
601      public Base setProperty(String name, Base value) throws FHIRException {
602        if (name.equals("contentType")) {
603          this.contentType = castToCode(value); // CodeType
604        } else if (name.equals("language")) {
605          this.language = castToCode(value); // CodeType
606        } else if (name.equals("data")) {
607          this.data = castToBase64Binary(value); // Base64BinaryType
608        } else if (name.equals("url")) {
609          this.url = castToUrl(value); // UrlType
610        } else if (name.equals("size")) {
611          this.size = castToUnsignedInt(value); // UnsignedIntType
612        } else if (name.equals("hash")) {
613          this.hash = castToBase64Binary(value); // Base64BinaryType
614        } else if (name.equals("title")) {
615          this.title = castToString(value); // StringType
616        } else if (name.equals("creation")) {
617          this.creation = castToDateTime(value); // DateTimeType
618        } else
619          return super.setProperty(name, value);
620        return value;
621      }
622
623      @Override
624      public Base makeProperty(int hash, String name) throws FHIRException {
625        switch (hash) {
626        case -389131437:  return getContentTypeElement();
627        case -1613589672:  return getLanguageElement();
628        case 3076010:  return getDataElement();
629        case 116079:  return getUrlElement();
630        case 3530753:  return getSizeElement();
631        case 3195150:  return getHashElement();
632        case 110371416:  return getTitleElement();
633        case 1820421855:  return getCreationElement();
634        default: return super.makeProperty(hash, name);
635        }
636
637      }
638
639      @Override
640      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
641        switch (hash) {
642        case -389131437: /*contentType*/ return new String[] {"code"};
643        case -1613589672: /*language*/ return new String[] {"code"};
644        case 3076010: /*data*/ return new String[] {"base64Binary"};
645        case 116079: /*url*/ return new String[] {"url"};
646        case 3530753: /*size*/ return new String[] {"unsignedInt"};
647        case 3195150: /*hash*/ return new String[] {"base64Binary"};
648        case 110371416: /*title*/ return new String[] {"string"};
649        case 1820421855: /*creation*/ return new String[] {"dateTime"};
650        default: return super.getTypesForProperty(hash, name);
651        }
652
653      }
654
655      @Override
656      public Base addChild(String name) throws FHIRException {
657        if (name.equals("contentType")) {
658          throw new FHIRException("Cannot call addChild on a primitive type Attachment.contentType");
659        }
660        else if (name.equals("language")) {
661          throw new FHIRException("Cannot call addChild on a primitive type Attachment.language");
662        }
663        else if (name.equals("data")) {
664          throw new FHIRException("Cannot call addChild on a primitive type Attachment.data");
665        }
666        else if (name.equals("url")) {
667          throw new FHIRException("Cannot call addChild on a primitive type Attachment.url");
668        }
669        else if (name.equals("size")) {
670          throw new FHIRException("Cannot call addChild on a primitive type Attachment.size");
671        }
672        else if (name.equals("hash")) {
673          throw new FHIRException("Cannot call addChild on a primitive type Attachment.hash");
674        }
675        else if (name.equals("title")) {
676          throw new FHIRException("Cannot call addChild on a primitive type Attachment.title");
677        }
678        else if (name.equals("creation")) {
679          throw new FHIRException("Cannot call addChild on a primitive type Attachment.creation");
680        }
681        else
682          return super.addChild(name);
683      }
684
685  public String fhirType() {
686    return "Attachment";
687
688  }
689
690      public Attachment copy() {
691        Attachment dst = new Attachment();
692        copyValues(dst);
693        dst.contentType = contentType == null ? null : contentType.copy();
694        dst.language = language == null ? null : language.copy();
695        dst.data = data == null ? null : data.copy();
696        dst.url = url == null ? null : url.copy();
697        dst.size = size == null ? null : size.copy();
698        dst.hash = hash == null ? null : hash.copy();
699        dst.title = title == null ? null : title.copy();
700        dst.creation = creation == null ? null : creation.copy();
701        return dst;
702      }
703
704      protected Attachment typedCopy() {
705        return copy();
706      }
707
708      @Override
709      public boolean equalsDeep(Base other_) {
710        if (!super.equalsDeep(other_))
711          return false;
712        if (!(other_ instanceof Attachment))
713          return false;
714        Attachment o = (Attachment) other_;
715        return compareDeep(contentType, o.contentType, true) && compareDeep(language, o.language, true)
716           && compareDeep(data, o.data, true) && compareDeep(url, o.url, true) && compareDeep(size, o.size, true)
717           && compareDeep(hash, o.hash, true) && compareDeep(title, o.title, true) && compareDeep(creation, o.creation, true)
718          ;
719      }
720
721      @Override
722      public boolean equalsShallow(Base other_) {
723        if (!super.equalsShallow(other_))
724          return false;
725        if (!(other_ instanceof Attachment))
726          return false;
727        Attachment o = (Attachment) other_;
728        return compareValues(contentType, o.contentType, true) && compareValues(language, o.language, true)
729           && compareValues(data, o.data, true) && compareValues(url, o.url, true) && compareValues(size, o.size, true)
730           && compareValues(hash, o.hash, true) && compareValues(title, o.title, true) && compareValues(creation, o.creation, true)
731          ;
732      }
733
734      public boolean isEmpty() {
735        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(contentType, language, data
736          , url, size, hash, title, creation);
737      }
738
739
740}
741