001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.List;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.ICompositeType;
037
038import ca.uhn.fhir.model.api.annotation.*;
039/**
040 * A set of ordered Quantities defined by a low and high limit.
041 */
042@DatatypeDef(name="Range")
043public class Range extends Type implements ICompositeType {
044
045    /**
046     * The low limit. The boundary is inclusive.
047     */
048    @Child(name = "low", type = {SimpleQuantity.class}, order=0, min=0, max=1, modifier=false, summary=true)
049    @Description(shortDefinition="Low limit", formalDefinition="The low limit. The boundary is inclusive." )
050    protected SimpleQuantity low;
051
052    /**
053     * The high limit. The boundary is inclusive.
054     */
055    @Child(name = "high", type = {SimpleQuantity.class}, order=1, min=0, max=1, modifier=false, summary=true)
056    @Description(shortDefinition="High limit", formalDefinition="The high limit. The boundary is inclusive." )
057    protected SimpleQuantity high;
058
059    private static final long serialVersionUID = 1699187994L;
060
061  /*
062   * Constructor
063   */
064    public Range() {
065      super();
066    }
067
068    /**
069     * @return {@link #low} (The low limit. The boundary is inclusive.)
070     */
071    public SimpleQuantity getLow() { 
072      if (this.low == null)
073        if (Configuration.errorOnAutoCreate())
074          throw new Error("Attempt to auto-create Range.low");
075        else if (Configuration.doAutoCreate())
076          this.low = new SimpleQuantity(); // cc
077      return this.low;
078    }
079
080    public boolean hasLow() { 
081      return this.low != null && !this.low.isEmpty();
082    }
083
084    /**
085     * @param value {@link #low} (The low limit. The boundary is inclusive.)
086     */
087    public Range setLow(SimpleQuantity value) { 
088      this.low = value;
089      return this;
090    }
091
092    /**
093     * @return {@link #high} (The high limit. The boundary is inclusive.)
094     */
095    public SimpleQuantity getHigh() { 
096      if (this.high == null)
097        if (Configuration.errorOnAutoCreate())
098          throw new Error("Attempt to auto-create Range.high");
099        else if (Configuration.doAutoCreate())
100          this.high = new SimpleQuantity(); // cc
101      return this.high;
102    }
103
104    public boolean hasHigh() { 
105      return this.high != null && !this.high.isEmpty();
106    }
107
108    /**
109     * @param value {@link #high} (The high limit. The boundary is inclusive.)
110     */
111    public Range setHigh(SimpleQuantity value) { 
112      this.high = value;
113      return this;
114    }
115
116      protected void listChildren(List<Property> childrenList) {
117        super.listChildren(childrenList);
118        childrenList.add(new Property("low", "SimpleQuantity", "The low limit. The boundary is inclusive.", 0, java.lang.Integer.MAX_VALUE, low));
119        childrenList.add(new Property("high", "SimpleQuantity", "The high limit. The boundary is inclusive.", 0, java.lang.Integer.MAX_VALUE, high));
120      }
121
122      @Override
123      public void setProperty(String name, Base value) throws FHIRException {
124        if (name.equals("low"))
125          this.low = castToSimpleQuantity(value); // SimpleQuantity
126        else if (name.equals("high"))
127          this.high = castToSimpleQuantity(value); // SimpleQuantity
128        else
129          super.setProperty(name, value);
130      }
131
132      @Override
133      public Base addChild(String name) throws FHIRException {
134        if (name.equals("low")) {
135          this.low = new SimpleQuantity();
136          return this.low;
137        }
138        else if (name.equals("high")) {
139          this.high = new SimpleQuantity();
140          return this.high;
141        }
142        else
143          return super.addChild(name);
144      }
145
146  public String fhirType() {
147    return "Range";
148
149  }
150
151      public Range copy() {
152        Range dst = new Range();
153        copyValues(dst);
154        dst.low = low == null ? null : low.copy();
155        dst.high = high == null ? null : high.copy();
156        return dst;
157      }
158
159      protected Range typedCopy() {
160        return copy();
161      }
162
163      @Override
164      public boolean equalsDeep(Base other) {
165        if (!super.equalsDeep(other))
166          return false;
167        if (!(other instanceof Range))
168          return false;
169        Range o = (Range) other;
170        return compareDeep(low, o.low, true) && compareDeep(high, o.high, true);
171      }
172
173      @Override
174      public boolean equalsShallow(Base other) {
175        if (!super.equalsShallow(other))
176          return false;
177        if (!(other instanceof Range))
178          return false;
179        Range o = (Range) other;
180        return true;
181      }
182
183      public boolean isEmpty() {
184        return super.isEmpty() && (low == null || low.isEmpty()) && (high == null || high.isEmpty())
185          ;
186      }
187
188
189}
190