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