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