001package org.hl7.fhir.r5.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r5
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.ArrayList;
054import java.util.Date;
055import java.util.List;
056import org.hl7.fhir.exceptions.FHIRException;
057import org.hl7.fhir.instance.model.api.ICompositeType;
058
059import org.hl7.fhir.instance.model.api.IAnyResource;
060import org.hl7.fhir.instance.model.api.IBaseReference;
061import org.hl7.fhir.instance.model.api.ICompositeType;
062import org.hl7.fhir.instance.model.api.IIdType;
063import org.hl7.fhir.utilities.Utilities;
064import ca.uhn.fhir.model.api.annotation.Child;
065import ca.uhn.fhir.model.api.annotation.ChildOrder;
066import ca.uhn.fhir.model.api.annotation.DatatypeDef;
067import ca.uhn.fhir.model.api.annotation.Description;
068import ca.uhn.fhir.model.api.annotation.Block;
069/**
070 * A reference from one resource to another.
071 */
072@DatatypeDef(name="Reference")
073public class Reference extends BaseReference implements IBaseReference, ICompositeType {
074
075    /**
076     * 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.
077     */
078    @Child(name = "reference", type = {StringType.class}, order=0, min=0, max=1, modifier=false, summary=true)
079    @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." )
080    protected StringType reference;
081
082    /**
083     * 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.
084
085The 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).
086     */
087    @Child(name = "type", type = {UriType.class}, order=1, min=0, max=1, modifier=false, summary=true)
088    @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)." )
089    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/resource-types")
090    protected UriType type;
091
092    /**
093     * 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.
094     */
095    @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=1, modifier=false, summary=true)
096    @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." )
097    protected Identifier identifier;
098
099    /**
100     * Plain text narrative that identifies the resource in addition to the resource reference.
101     */
102    @Child(name = "display", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
103    @Description(shortDefinition="Text alternative for the resource", formalDefinition="Plain text narrative that identifies the resource in addition to the resource reference." )
104    protected StringType display;
105
106    private static final long serialVersionUID = 784245805L;
107
108  /**
109   * Constructor
110   */
111    public Reference() {
112      super();
113    }
114
115    /**
116     * Constructor
117     * 
118     * @param theReference The given reference string (e.g. "Patient/123" or "http://example.com/Patient/123")
119     */
120    public Reference(String theReference) {
121      super(theReference);
122    }
123
124    /**
125     * Constructor
126     * 
127     * @param theReference The given reference as an IdType (e.g. "Patient/123" or "http://example.com/Patient/123")
128     */
129    public Reference(IIdType theReference) {
130      super(theReference);
131    }
132
133    /**
134     * Constructor
135     * 
136     * @param theResource The resource represented by this reference
137     */
138    public Reference(IAnyResource theResource) {
139      super(theResource);
140    }
141
142    /**
143     * @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
144     */
145    public StringType getReferenceElement_() { 
146      if (this.reference == null)
147        if (Configuration.errorOnAutoCreate())
148          throw new Error("Attempt to auto-create Reference.reference");
149        else if (Configuration.doAutoCreate())
150          this.reference = new StringType(); // bb
151      return this.reference;
152    }
153
154    public boolean hasReferenceElement() { 
155      return this.reference != null && !this.reference.isEmpty();
156    }
157
158    public boolean hasReference() { 
159      return this.reference != null && !this.reference.isEmpty();
160    }
161
162    /**
163     * @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
164     */
165    public Reference setReferenceElement(StringType value) { 
166      this.reference = value;
167      return this;
168    }
169
170    /**
171     * @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.
172     */
173    public String getReference() { 
174      return this.reference == null ? null : this.reference.getValue();
175    }
176
177    /**
178     * @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.
179     */
180    public Reference setReference(String value) { 
181      if (Utilities.noString(value))
182        this.reference = null;
183      else {
184        if (this.reference == null)
185          this.reference = new StringType();
186        this.reference.setValue(value);
187      }
188      return this;
189    }
190
191    /**
192     * @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.
193
194The 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
195     */
196    public UriType getTypeElement() { 
197      if (this.type == null)
198        if (Configuration.errorOnAutoCreate())
199          throw new Error("Attempt to auto-create Reference.type");
200        else if (Configuration.doAutoCreate())
201          this.type = new UriType(); // bb
202      return this.type;
203    }
204
205    public boolean hasTypeElement() { 
206      return this.type != null && !this.type.isEmpty();
207    }
208
209    public boolean hasType() { 
210      return this.type != null && !this.type.isEmpty();
211    }
212
213    /**
214     * @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.
215
216The 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
217     */
218    public Reference setTypeElement(UriType value) { 
219      this.type = value;
220      return this;
221    }
222
223    /**
224     * @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.
225
226The 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).
227     */
228    public String getType() { 
229      return this.type == null ? null : this.type.getValue();
230    }
231
232    /**
233     * @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.
234
235The 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).
236     */
237    public Reference setType(String value) { 
238      if (Utilities.noString(value))
239        this.type = null;
240      else {
241        if (this.type == null)
242          this.type = new UriType();
243        this.type.setValue(value);
244      }
245      return this;
246    }
247
248    /**
249     * @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.)
250     */
251    public Identifier getIdentifier() { 
252      if (this.identifier == null)
253        if (Configuration.errorOnAutoCreate())
254          throw new Error("Attempt to auto-create Reference.identifier");
255        else if (Configuration.doAutoCreate())
256          this.identifier = new Identifier(); // cc
257      return this.identifier;
258    }
259
260    public boolean hasIdentifier() { 
261      return this.identifier != null && !this.identifier.isEmpty();
262    }
263
264    /**
265     * @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.)
266     */
267    public Reference setIdentifier(Identifier value) { 
268      this.identifier = value;
269      return this;
270    }
271
272    /**
273     * @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
274     */
275    public StringType getDisplayElement() { 
276      if (this.display == null)
277        if (Configuration.errorOnAutoCreate())
278          throw new Error("Attempt to auto-create Reference.display");
279        else if (Configuration.doAutoCreate())
280          this.display = new StringType(); // bb
281      return this.display;
282    }
283
284    public boolean hasDisplayElement() { 
285      return this.display != null && !this.display.isEmpty();
286    }
287
288    public boolean hasDisplay() { 
289      return this.display != null && !this.display.isEmpty();
290    }
291
292    /**
293     * @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
294     */
295    public Reference setDisplayElement(StringType value) { 
296      this.display = value;
297      return this;
298    }
299
300    /**
301     * @return Plain text narrative that identifies the resource in addition to the resource reference.
302     */
303    public String getDisplay() { 
304      return this.display == null ? null : this.display.getValue();
305    }
306
307    /**
308     * @param value Plain text narrative that identifies the resource in addition to the resource reference.
309     */
310    public Reference setDisplay(String value) { 
311      if (Utilities.noString(value))
312        this.display = null;
313      else {
314        if (this.display == null)
315          this.display = new StringType();
316        this.display.setValue(value);
317      }
318      return this;
319    }
320
321 /**
322   * Convenience setter which sets the reference to the complete {@link IIdType#getValue() value} of the given
323   * reference.
324   *
325   * @param theReference The reference, or <code>null</code>
326   * @return 
327   * @return Returns a reference to this
328   */
329  public Reference setReferenceElement(IIdType theReference) {
330    if (theReference != null) {
331      setReference(theReference.getValue());
332    } else {
333      setReference(null);
334    }
335    return this;
336  }
337      protected void listChildren(List<Property> children) {
338        super.listChildren(children);
339        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));
340        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));
341        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));
342        children.add(new Property("display", "string", "Plain text narrative that identifies the resource in addition to the resource reference.", 0, 1, display));
343      }
344
345      @Override
346      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
347        switch (_hash) {
348        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);
349        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);
350        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);
351        case 1671764162: /*display*/  return new Property("display", "string", "Plain text narrative that identifies the resource in addition to the resource reference.", 0, 1, display);
352        default: return super.getNamedProperty(_hash, _name, _checkValid);
353        }
354
355      }
356
357      @Override
358      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
359        switch (hash) {
360        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // StringType
361        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // UriType
362        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
363        case 1671764162: /*display*/ return this.display == null ? new Base[0] : new Base[] {this.display}; // StringType
364        default: return super.getProperty(hash, name, checkValid);
365        }
366
367      }
368
369      @Override
370      public Base setProperty(int hash, String name, Base value) throws FHIRException {
371        switch (hash) {
372        case -925155509: // reference
373          this.reference = castToString(value); // StringType
374          return value;
375        case 3575610: // type
376          this.type = castToUri(value); // UriType
377          return value;
378        case -1618432855: // identifier
379          this.identifier = castToIdentifier(value); // Identifier
380          return value;
381        case 1671764162: // display
382          this.display = castToString(value); // StringType
383          return value;
384        default: return super.setProperty(hash, name, value);
385        }
386
387      }
388
389      @Override
390      public Base setProperty(String name, Base value) throws FHIRException {
391        if (name.equals("reference")) {
392          this.reference = castToString(value); // StringType
393        } else if (name.equals("type")) {
394          this.type = castToUri(value); // UriType
395        } else if (name.equals("identifier")) {
396          this.identifier = castToIdentifier(value); // Identifier
397        } else if (name.equals("display")) {
398          this.display = castToString(value); // StringType
399        } else
400          return super.setProperty(name, value);
401        return value;
402      }
403
404      @Override
405      public Base makeProperty(int hash, String name) throws FHIRException {
406        switch (hash) {
407        case -925155509:  return getReferenceElement_();
408        case 3575610:  return getTypeElement();
409        case -1618432855:  return getIdentifier();
410        case 1671764162:  return getDisplayElement();
411        default: return super.makeProperty(hash, name);
412        }
413
414      }
415
416      @Override
417      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
418        switch (hash) {
419        case -925155509: /*reference*/ return new String[] {"string"};
420        case 3575610: /*type*/ return new String[] {"uri"};
421        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
422        case 1671764162: /*display*/ return new String[] {"string"};
423        default: return super.getTypesForProperty(hash, name);
424        }
425
426      }
427
428      @Override
429      public Base addChild(String name) throws FHIRException {
430        if (name.equals("reference")) {
431          throw new FHIRException("Cannot call addChild on a primitive type Reference.reference");
432        }
433        else if (name.equals("type")) {
434          throw new FHIRException("Cannot call addChild on a primitive type Reference.type");
435        }
436        else if (name.equals("identifier")) {
437          this.identifier = new Identifier();
438          return this.identifier;
439        }
440        else if (name.equals("display")) {
441          throw new FHIRException("Cannot call addChild on a primitive type Reference.display");
442        }
443        else
444          return super.addChild(name);
445      }
446
447  public String fhirType() {
448    return "Reference";
449
450  }
451
452      public Reference copy() {
453        Reference dst = new Reference();
454        copyValues(dst);
455        return dst;
456      }
457
458      public void copyValues(Reference dst) {
459        super.copyValues(dst);
460        dst.reference = reference == null ? null : reference.copy();
461        dst.type = type == null ? null : type.copy();
462        dst.identifier = identifier == null ? null : identifier.copy();
463        dst.display = display == null ? null : display.copy();
464      }
465
466      protected Reference typedCopy() {
467        return copy();
468      }
469
470      @Override
471      public boolean equalsDeep(Base other_) {
472        if (!super.equalsDeep(other_))
473          return false;
474        if (!(other_ instanceof Reference))
475          return false;
476        Reference o = (Reference) other_;
477        return compareDeep(reference, o.reference, true) && compareDeep(type, o.type, true) && compareDeep(identifier, o.identifier, true)
478           && compareDeep(display, o.display, true);
479      }
480
481      @Override
482      public boolean equalsShallow(Base other_) {
483        if (!super.equalsShallow(other_))
484          return false;
485        if (!(other_ instanceof Reference))
486          return false;
487        Reference o = (Reference) other_;
488        return compareValues(reference, o.reference, true) && compareValues(type, o.type, true) && compareValues(display, o.display, true)
489          ;
490      }
491
492      public boolean isEmpty() {
493        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(reference, type, identifier
494          , display);
495      }
496
497// added from java-adornments.txt:
498
499    @Override
500      public String toString() {
501        if (hasReference())
502          return "Reference["+getReference()+"]";
503        if (hasIdentifier())
504          return "Reference[id:"+getIdentifier()+"]";
505        if (hasDisplay())
506          return "Reference['"+getDisplay()+"']";
507        return "Reference[??]";
508      }
509
510
511// end addition
512
513}
514