001package org.hl7.fhir.r5.model;
002
003
004/*
005 * #%L
006 * org.hl7.fhir.r5
007 * %%
008 * Copyright (C) 2014 - 2019 Health Level 7
009 * %%
010 * Licensed under the Apache License, Version 2.0 (the \"License\");
011 * you may not use this file except in compliance with the License.
012 * You may obtain a copy of the License at
013 * 
014 *      http://www.apache.org/licenses/LICENSE-2.0
015 * 
016 * Unless required by applicable law or agreed to in writing, software
017 * distributed under the License is distributed on an \"AS IS\" BASIS,
018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019 * See the License for the specific language governing permissions and
020 * limitations under the License.
021 * #L%
022 */
023
024/*
025  Copyright (c) 2011+, HL7, Inc.
026  All rights reserved.
027  
028  Redistribution and use in source and binary forms, with or without modification, \
029  are permitted provided that the following conditions are met:
030  
031   * Redistributions of source code must retain the above copyright notice, this \
032     list of conditions and the following disclaimer.
033   * Redistributions in binary form must reproduce the above copyright notice, \
034     this list of conditions and the following disclaimer in the documentation \
035     and/or other materials provided with the distribution.
036   * Neither the name of HL7 nor the names of its contributors may be used to 
037     endorse or promote products derived from this software without specific 
038     prior written permission.
039  
040  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
041  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
042  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
043  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
044  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
045  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
046  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
047  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
048  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
049  POSSIBILITY OF SUCH DAMAGE.
050  */
051
052// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent
053
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057import org.hl7.fhir.utilities.Utilities;
058import org.hl7.fhir.r5.model.Enumerations.*;
059import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
060import org.hl7.fhir.exceptions.FHIRException;
061import org.hl7.fhir.instance.model.api.ICompositeType;
062import ca.uhn.fhir.model.api.annotation.Child;
063import ca.uhn.fhir.model.api.annotation.ChildOrder;
064import ca.uhn.fhir.model.api.annotation.DatatypeDef;
065import ca.uhn.fhir.model.api.annotation.Description;
066import ca.uhn.fhir.model.api.annotation.Block;
067
068import org.hl7.fhir.instance.model.api.IAnyResource;
069import  org.hl7.fhir.instance.model.api.IBaseReference;
070import  org.hl7.fhir.instance.model.api.ICompositeType;
071import  org.hl7.fhir.instance.model.api.IIdType;
072/**
073 * Base StructureDefinition for Reference Type: A reference from one resource to another.
074 */
075@DatatypeDef(name="Reference")
076public class Reference extends BaseReference implements IBaseReference, ICompositeType {
077
078    /**
079     * A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.
080     */
081    @Child(name = "reference", type = {StringType.class}, order=0, min=0, max=1, modifier=false, summary=true)
082    @Description(shortDefinition="Literal reference, Relative, internal or absolute URL", formalDefinition="A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources." )
083    protected StringType reference;
084
085    /**
086     * The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.
087
088The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).
089     */
090    @Child(name = "type", type = {UriType.class}, order=1, min=0, max=1, modifier=false, summary=true)
091    @Description(shortDefinition="Type the reference refers to (e.g. \"Patient\")", formalDefinition="The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.\n\nThe type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. \"Patient\" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources)." )
092    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/resource-types")
093    protected UriType type;
094
095    /**
096     * An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.
097     */
098    @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=1, modifier=false, summary=true)
099    @Description(shortDefinition="Logical reference, when literal reference is not known", formalDefinition="An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference." )
100    protected Identifier identifier;
101
102    /**
103     * Plain text narrative that identifies the resource in addition to the resource reference.
104     */
105    @Child(name = "display", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
106    @Description(shortDefinition="Text alternative for the resource", formalDefinition="Plain text narrative that identifies the resource in addition to the resource reference." )
107    protected StringType display;
108
109    private static final long serialVersionUID = 784245805L;
110
111  /**
112   * Constructor
113   */
114    public Reference() {
115      super();
116    }
117
118    /**
119     * Constructor
120     * 
121     * @param theReference The given reference string (e.g. "Patient/123" or "http://example.com/Patient/123")
122     */
123    public Reference(String theReference) {
124      super(theReference);
125    }
126
127    /**
128     * Constructor
129     * 
130     * @param theReference The given reference as an IdType (e.g. "Patient/123" or "http://example.com/Patient/123")
131     */
132    public Reference(IIdType theReference) {
133      super(theReference);
134    }
135
136    /**
137     * Constructor
138     * 
139     * @param theResource The resource represented by this reference
140     */
141    public Reference(IAnyResource theResource) {
142      super(theResource);
143    }
144
145    /**
146     * @return {@link #reference} (A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.). This is the underlying object with id, value and extensions. The accessor "getReference" gives direct access to the value
147     */
148    public StringType getReferenceElement_() { 
149      if (this.reference == null)
150        if (Configuration.errorOnAutoCreate())
151          throw new Error("Attempt to auto-create Reference.reference");
152        else if (Configuration.doAutoCreate())
153          this.reference = new StringType(); // bb
154      return this.reference;
155    }
156
157    public boolean hasReferenceElement() { 
158      return this.reference != null && !this.reference.isEmpty();
159    }
160
161    public boolean hasReference() { 
162      return this.reference != null && !this.reference.isEmpty();
163    }
164
165    /**
166     * @param value {@link #reference} (A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.). This is the underlying object with id, value and extensions. The accessor "getReference" gives direct access to the value
167     */
168    public Reference setReferenceElement(StringType value) { 
169      this.reference = value;
170      return this;
171    }
172
173    /**
174     * @return A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.
175     */
176    public String getReference() { 
177      return this.reference == null ? null : this.reference.getValue();
178    }
179
180    /**
181     * @param value A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.
182     */
183    public Reference setReference(String value) { 
184      if (Utilities.noString(value))
185        this.reference = null;
186      else {
187        if (this.reference == null)
188          this.reference = new StringType();
189        this.reference.setValue(value);
190      }
191      return this;
192    }
193
194    /**
195     * @return {@link #type} (The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.
196
197The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
198     */
199    public UriType getTypeElement() { 
200      if (this.type == null)
201        if (Configuration.errorOnAutoCreate())
202          throw new Error("Attempt to auto-create Reference.type");
203        else if (Configuration.doAutoCreate())
204          this.type = new UriType(); // bb
205      return this.type;
206    }
207
208    public boolean hasTypeElement() { 
209      return this.type != null && !this.type.isEmpty();
210    }
211
212    public boolean hasType() { 
213      return this.type != null && !this.type.isEmpty();
214    }
215
216    /**
217     * @param value {@link #type} (The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.
218
219The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
220     */
221    public Reference setTypeElement(UriType value) { 
222      this.type = value;
223      return this;
224    }
225
226    /**
227     * @return The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.
228
229The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).
230     */
231    public String getType() { 
232      return this.type == null ? null : this.type.getValue();
233    }
234
235    /**
236     * @param value The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.
237
238The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).
239     */
240    public Reference setType(String value) { 
241      if (Utilities.noString(value))
242        this.type = null;
243      else {
244        if (this.type == null)
245          this.type = new UriType();
246        this.type.setValue(value);
247      }
248      return this;
249    }
250
251    /**
252     * @return {@link #identifier} (An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.)
253     */
254    public Identifier getIdentifier() { 
255      if (this.identifier == null)
256        if (Configuration.errorOnAutoCreate())
257          throw new Error("Attempt to auto-create Reference.identifier");
258        else if (Configuration.doAutoCreate())
259          this.identifier = new Identifier(); // cc
260      return this.identifier;
261    }
262
263    public boolean hasIdentifier() { 
264      return this.identifier != null && !this.identifier.isEmpty();
265    }
266
267    /**
268     * @param value {@link #identifier} (An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.)
269     */
270    public Reference setIdentifier(Identifier value) { 
271      this.identifier = value;
272      return this;
273    }
274
275    /**
276     * @return {@link #display} (Plain text narrative that identifies the resource in addition to the resource reference.). This is the underlying object with id, value and extensions. The accessor "getDisplay" gives direct access to the value
277     */
278    public StringType getDisplayElement() { 
279      if (this.display == null)
280        if (Configuration.errorOnAutoCreate())
281          throw new Error("Attempt to auto-create Reference.display");
282        else if (Configuration.doAutoCreate())
283          this.display = new StringType(); // bb
284      return this.display;
285    }
286
287    public boolean hasDisplayElement() { 
288      return this.display != null && !this.display.isEmpty();
289    }
290
291    public boolean hasDisplay() { 
292      return this.display != null && !this.display.isEmpty();
293    }
294
295    /**
296     * @param value {@link #display} (Plain text narrative that identifies the resource in addition to the resource reference.). This is the underlying object with id, value and extensions. The accessor "getDisplay" gives direct access to the value
297     */
298    public Reference setDisplayElement(StringType value) { 
299      this.display = value;
300      return this;
301    }
302
303    /**
304     * @return Plain text narrative that identifies the resource in addition to the resource reference.
305     */
306    public String getDisplay() { 
307      return this.display == null ? null : this.display.getValue();
308    }
309
310    /**
311     * @param value Plain text narrative that identifies the resource in addition to the resource reference.
312     */
313    public Reference setDisplay(String value) { 
314      if (Utilities.noString(value))
315        this.display = null;
316      else {
317        if (this.display == null)
318          this.display = new StringType();
319        this.display.setValue(value);
320      }
321      return this;
322    }
323
324      protected void listChildren(List<Property> children) {
325        super.listChildren(children);
326        children.add(new Property("reference", "string", "A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.", 0, 1, reference));
327        children.add(new Property("type", "uri", "The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.\n\nThe type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. \"Patient\" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).", 0, 1, type));
328        children.add(new Property("identifier", "Identifier", "An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.", 0, 1, identifier));
329        children.add(new Property("display", "string", "Plain text narrative that identifies the resource in addition to the resource reference.", 0, 1, display));
330      }
331
332      @Override
333      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
334        switch (_hash) {
335        case -925155509: /*reference*/  return new Property("reference", "string", "A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.", 0, 1, reference);
336        case 3575610: /*type*/  return new Property("type", "uri", "The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.\n\nThe type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. \"Patient\" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).", 0, 1, type);
337        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.", 0, 1, identifier);
338        case 1671764162: /*display*/  return new Property("display", "string", "Plain text narrative that identifies the resource in addition to the resource reference.", 0, 1, display);
339        default: return super.getNamedProperty(_hash, _name, _checkValid);
340        }
341
342      }
343
344      @Override
345      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
346        switch (hash) {
347        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // StringType
348        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // UriType
349        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
350        case 1671764162: /*display*/ return this.display == null ? new Base[0] : new Base[] {this.display}; // StringType
351        default: return super.getProperty(hash, name, checkValid);
352        }
353
354      }
355
356      @Override
357      public Base setProperty(int hash, String name, Base value) throws FHIRException {
358        switch (hash) {
359        case -925155509: // reference
360          this.reference = TypeConvertor.castToString(value); // StringType
361          return value;
362        case 3575610: // type
363          this.type = TypeConvertor.castToUri(value); // UriType
364          return value;
365        case -1618432855: // identifier
366          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
367          return value;
368        case 1671764162: // display
369          this.display = TypeConvertor.castToString(value); // StringType
370          return value;
371        default: return super.setProperty(hash, name, value);
372        }
373
374      }
375
376      @Override
377      public Base setProperty(String name, Base value) throws FHIRException {
378        if (name.equals("reference")) {
379          this.reference = TypeConvertor.castToString(value); // StringType
380        } else if (name.equals("type")) {
381          this.type = TypeConvertor.castToUri(value); // UriType
382        } else if (name.equals("identifier")) {
383          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
384        } else if (name.equals("display")) {
385          this.display = TypeConvertor.castToString(value); // StringType
386        } else
387          return super.setProperty(name, value);
388        return value;
389      }
390
391      @Override
392      public Base makeProperty(int hash, String name) throws FHIRException {
393        switch (hash) {
394        case -925155509:  return getReferenceElement_();
395        case 3575610:  return getTypeElement();
396        case -1618432855:  return getIdentifier();
397        case 1671764162:  return getDisplayElement();
398        default: return super.makeProperty(hash, name);
399        }
400
401      }
402
403      @Override
404      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
405        switch (hash) {
406        case -925155509: /*reference*/ return new String[] {"string"};
407        case 3575610: /*type*/ return new String[] {"uri"};
408        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
409        case 1671764162: /*display*/ return new String[] {"string"};
410        default: return super.getTypesForProperty(hash, name);
411        }
412
413      }
414
415      @Override
416      public Base addChild(String name) throws FHIRException {
417        if (name.equals("reference")) {
418          throw new FHIRException("Cannot call addChild on a primitive type Reference.reference");
419        }
420        else if (name.equals("type")) {
421          throw new FHIRException("Cannot call addChild on a primitive type Reference.type");
422        }
423        else if (name.equals("identifier")) {
424          this.identifier = new Identifier();
425          return this.identifier;
426        }
427        else if (name.equals("display")) {
428          throw new FHIRException("Cannot call addChild on a primitive type Reference.display");
429        }
430        else
431          return super.addChild(name);
432      }
433
434  public String fhirType() {
435    return "Reference";
436
437  }
438
439      public Reference copy() {
440        Reference dst = new Reference();
441        copyValues(dst);
442        return dst;
443      }
444
445      public void copyValues(Reference dst) {
446        super.copyValues(dst);
447        dst.reference = reference == null ? null : reference.copy();
448        dst.type = type == null ? null : type.copy();
449        dst.identifier = identifier == null ? null : identifier.copy();
450        dst.display = display == null ? null : display.copy();
451      }
452
453      protected Reference typedCopy() {
454        return copy();
455      }
456
457      @Override
458      public boolean equalsDeep(Base other_) {
459        if (!super.equalsDeep(other_))
460          return false;
461        if (!(other_ instanceof Reference))
462          return false;
463        Reference o = (Reference) other_;
464        return compareDeep(reference, o.reference, true) && compareDeep(type, o.type, true) && compareDeep(identifier, o.identifier, true)
465           && compareDeep(display, o.display, true);
466      }
467
468      @Override
469      public boolean equalsShallow(Base other_) {
470        if (!super.equalsShallow(other_))
471          return false;
472        if (!(other_ instanceof Reference))
473          return false;
474        Reference o = (Reference) other_;
475        return compareValues(reference, o.reference, true) && compareValues(type, o.type, true) && compareValues(display, o.display, true)
476          ;
477      }
478
479      public boolean isEmpty() {
480        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(reference, type, identifier
481          , display);
482      }
483
484// Manual code (from Configuration.txt)t:
485
486    @Override
487      public String toString() {
488        if (hasReference())
489          return "Reference["+getReference()+"]";
490        if (hasIdentifier())
491          return "Reference[id:"+getIdentifier()+"]";
492        if (hasDisplay())
493          return "Reference['"+getDisplay()+"']";
494        return "Reference[??]";
495      }
496
497 /** 
498   * Convenience setter which sets the reference to the complete {@link IIdType#getValue() value} of the given 
499   * reference. 
500   * 
501   * @param theReference The reference, or <code>null</code> 
502   * @return  
503   * @return Returns a reference to this 
504   */ 
505  public Reference setReferenceElement(IIdType theReference) { 
506    if (theReference != null) { 
507      setReference(theReference.getValue()); 
508    } else { 
509      setReference(null); 
510    } 
511    return this; 
512  } 
513
514// end addition
515
516}
517