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