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 relationship of two Quantity values - expressed as a numerator and a denominator.
063 */
064@DatatypeDef(name="Ratio")
065public class Ratio extends Type implements ICompositeType {
066
067    /**
068     * The value of the numerator.
069     */
070    @Child(name = "numerator", type = {Quantity.class}, order=0, min=0, max=1, modifier=false, summary=true)
071    @Description(shortDefinition="Numerator value", formalDefinition="The value of the numerator." )
072    protected Quantity numerator;
073
074    /**
075     * The value of the denominator.
076     */
077    @Child(name = "denominator", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=true)
078    @Description(shortDefinition="Denominator value", formalDefinition="The value of the denominator." )
079    protected Quantity denominator;
080
081    private static final long serialVersionUID = 479922563L;
082
083  /*
084   * Constructor
085   */
086    public Ratio() {
087      super();
088    }
089
090    /**
091     * @return {@link #numerator} (The value of the numerator.)
092     */
093    public Quantity getNumerator() { 
094      if (this.numerator == null)
095        if (Configuration.errorOnAutoCreate())
096          throw new Error("Attempt to auto-create Ratio.numerator");
097        else if (Configuration.doAutoCreate())
098          this.numerator = new Quantity(); // cc
099      return this.numerator;
100    }
101
102    public boolean hasNumerator() { 
103      return this.numerator != null && !this.numerator.isEmpty();
104    }
105
106    /**
107     * @param value {@link #numerator} (The value of the numerator.)
108     */
109    public Ratio setNumerator(Quantity value) { 
110      this.numerator = value;
111      return this;
112    }
113
114    /**
115     * @return {@link #denominator} (The value of the denominator.)
116     */
117    public Quantity getDenominator() { 
118      if (this.denominator == null)
119        if (Configuration.errorOnAutoCreate())
120          throw new Error("Attempt to auto-create Ratio.denominator");
121        else if (Configuration.doAutoCreate())
122          this.denominator = new Quantity(); // cc
123      return this.denominator;
124    }
125
126    public boolean hasDenominator() { 
127      return this.denominator != null && !this.denominator.isEmpty();
128    }
129
130    /**
131     * @param value {@link #denominator} (The value of the denominator.)
132     */
133    public Ratio setDenominator(Quantity value) { 
134      this.denominator = value;
135      return this;
136    }
137
138      protected void listChildren(List<Property> childrenList) {
139        super.listChildren(childrenList);
140        childrenList.add(new Property("numerator", "Quantity", "The value of the numerator.", 0, java.lang.Integer.MAX_VALUE, numerator));
141        childrenList.add(new Property("denominator", "Quantity", "The value of the denominator.", 0, java.lang.Integer.MAX_VALUE, denominator));
142      }
143
144      @Override
145      public void setProperty(String name, Base value) throws FHIRException {
146        if (name.equals("numerator"))
147          this.numerator = castToQuantity(value); // Quantity
148        else if (name.equals("denominator"))
149          this.denominator = castToQuantity(value); // Quantity
150        else
151          super.setProperty(name, value);
152      }
153
154      @Override
155      public Base addChild(String name) throws FHIRException {
156        if (name.equals("numerator")) {
157          this.numerator = new Quantity();
158          return this.numerator;
159        }
160        else if (name.equals("denominator")) {
161          this.denominator = new Quantity();
162          return this.denominator;
163        }
164        else
165          return super.addChild(name);
166      }
167
168  public String fhirType() {
169    return "Ratio";
170
171  }
172
173      public Ratio copy() {
174        Ratio dst = new Ratio();
175        copyValues(dst);
176        dst.numerator = numerator == null ? null : numerator.copy();
177        dst.denominator = denominator == null ? null : denominator.copy();
178        return dst;
179      }
180
181      protected Ratio 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 Ratio))
190          return false;
191        Ratio o = (Ratio) other;
192        return compareDeep(numerator, o.numerator, true) && compareDeep(denominator, o.denominator, true)
193          ;
194      }
195
196      @Override
197      public boolean equalsShallow(Base other) {
198        if (!super.equalsShallow(other))
199          return false;
200        if (!(other instanceof Ratio))
201          return false;
202        Ratio o = (Ratio) other;
203        return true;
204      }
205
206      public boolean isEmpty() {
207        return super.isEmpty() && (numerator == null || numerator.isEmpty()) && (denominator == null || denominator.isEmpty())
208          ;
209      }
210
211
212}
213