001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
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.Child;
039import ca.uhn.fhir.model.api.annotation.DatatypeDef;
040import ca.uhn.fhir.model.api.annotation.Description;
041/**
042 * A set of ordered Quantities defined by a low and high limit.
043 */
044@DatatypeDef(name="Range")
045public class Range extends Type implements ICompositeType {
046
047    /**
048     * The low limit. The boundary is inclusive.
049     */
050    @Child(name = "low", type = {SimpleQuantity.class}, order=0, min=0, max=1, modifier=false, summary=true)
051    @Description(shortDefinition="Low limit", formalDefinition="The low limit. The boundary is inclusive." )
052    protected SimpleQuantity low;
053
054    /**
055     * The high limit. The boundary is inclusive.
056     */
057    @Child(name = "high", type = {SimpleQuantity.class}, order=1, min=0, max=1, modifier=false, summary=true)
058    @Description(shortDefinition="High limit", formalDefinition="The high limit. The boundary is inclusive." )
059    protected SimpleQuantity high;
060
061    private static final long serialVersionUID = 1699187994L;
062
063  /**
064   * Constructor
065   */
066    public Range() {
067      super();
068    }
069
070    /**
071     * @return {@link #low} (The low limit. The boundary is inclusive.)
072     */
073    public SimpleQuantity getLow() { 
074      if (this.low == null)
075        if (Configuration.errorOnAutoCreate())
076          throw new Error("Attempt to auto-create Range.low");
077        else if (Configuration.doAutoCreate())
078          this.low = new SimpleQuantity(); // cc
079      return this.low;
080    }
081
082    public boolean hasLow() { 
083      return this.low != null && !this.low.isEmpty();
084    }
085
086    /**
087     * @param value {@link #low} (The low limit. The boundary is inclusive.)
088     */
089    public Range setLow(SimpleQuantity value) { 
090      this.low = value;
091      return this;
092    }
093
094    /**
095     * @return {@link #high} (The high limit. The boundary is inclusive.)
096     */
097    public SimpleQuantity getHigh() { 
098      if (this.high == null)
099        if (Configuration.errorOnAutoCreate())
100          throw new Error("Attempt to auto-create Range.high");
101        else if (Configuration.doAutoCreate())
102          this.high = new SimpleQuantity(); // cc
103      return this.high;
104    }
105
106    public boolean hasHigh() { 
107      return this.high != null && !this.high.isEmpty();
108    }
109
110    /**
111     * @param value {@link #high} (The high limit. The boundary is inclusive.)
112     */
113    public Range setHigh(SimpleQuantity value) { 
114      this.high = value;
115      return this;
116    }
117
118      protected void listChildren(List<Property> childrenList) {
119        super.listChildren(childrenList);
120        childrenList.add(new Property("low", "SimpleQuantity", "The low limit. The boundary is inclusive.", 0, java.lang.Integer.MAX_VALUE, low));
121        childrenList.add(new Property("high", "SimpleQuantity", "The high limit. The boundary is inclusive.", 0, java.lang.Integer.MAX_VALUE, high));
122      }
123
124      @Override
125      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
126        switch (hash) {
127        case 107348: /*low*/ return this.low == null ? new Base[0] : new Base[] {this.low}; // SimpleQuantity
128        case 3202466: /*high*/ return this.high == null ? new Base[0] : new Base[] {this.high}; // SimpleQuantity
129        default: return super.getProperty(hash, name, checkValid);
130        }
131
132      }
133
134      @Override
135      public void setProperty(int hash, String name, Base value) throws FHIRException {
136        switch (hash) {
137        case 107348: // low
138          this.low = castToSimpleQuantity(value); // SimpleQuantity
139          break;
140        case 3202466: // high
141          this.high = castToSimpleQuantity(value); // SimpleQuantity
142          break;
143        default: super.setProperty(hash, name, value);
144        }
145
146      }
147
148      @Override
149      public void setProperty(String name, Base value) throws FHIRException {
150        if (name.equals("low"))
151          this.low = castToSimpleQuantity(value); // SimpleQuantity
152        else if (name.equals("high"))
153          this.high = castToSimpleQuantity(value); // SimpleQuantity
154        else
155          super.setProperty(name, value);
156      }
157
158      @Override
159      public Base makeProperty(int hash, String name) throws FHIRException {
160        switch (hash) {
161        case 107348:  return getLow(); // SimpleQuantity
162        case 3202466:  return getHigh(); // SimpleQuantity
163        default: return super.makeProperty(hash, name);
164        }
165
166      }
167
168      @Override
169      public Base addChild(String name) throws FHIRException {
170        if (name.equals("low")) {
171          this.low = new SimpleQuantity();
172          return this.low;
173        }
174        else if (name.equals("high")) {
175          this.high = new SimpleQuantity();
176          return this.high;
177        }
178        else
179          return super.addChild(name);
180      }
181
182  public String fhirType() {
183    return "Range";
184
185  }
186
187      public Range copy() {
188        Range dst = new Range();
189        copyValues(dst);
190        dst.low = low == null ? null : low.copy();
191        dst.high = high == null ? null : high.copy();
192        return dst;
193      }
194
195      protected Range typedCopy() {
196        return copy();
197      }
198
199      @Override
200      public boolean equalsDeep(Base other) {
201        if (!super.equalsDeep(other))
202          return false;
203        if (!(other instanceof Range))
204          return false;
205        Range o = (Range) other;
206        return compareDeep(low, o.low, true) && compareDeep(high, o.high, true);
207      }
208
209      @Override
210      public boolean equalsShallow(Base other) {
211        if (!super.equalsShallow(other))
212          return false;
213        if (!(other instanceof Range))
214          return false;
215        Range o = (Range) other;
216        return true;
217      }
218
219      public boolean isEmpty() {
220        return super.isEmpty() && (low == null || low.isEmpty()) && (high == null || high.isEmpty())
221          ;
222      }
223
224
225}
226