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 relationship of two Quantity values - expressed as a numerator and a denominator. 043 */ 044@DatatypeDef(name="Ratio") 045public class Ratio extends Type implements ICompositeType { 046 047 /** 048 * The value of the numerator. 049 */ 050 @Child(name = "numerator", type = {Quantity.class}, order=0, min=0, max=1, modifier=false, summary=true) 051 @Description(shortDefinition="Numerator value", formalDefinition="The value of the numerator." ) 052 protected Quantity numerator; 053 054 /** 055 * The value of the denominator. 056 */ 057 @Child(name = "denominator", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=true) 058 @Description(shortDefinition="Denominator value", formalDefinition="The value of the denominator." ) 059 protected Quantity denominator; 060 061 private static final long serialVersionUID = 479922563L; 062 063 /** 064 * Constructor 065 */ 066 public Ratio() { 067 super(); 068 } 069 070 /** 071 * @return {@link #numerator} (The value of the numerator.) 072 */ 073 public Quantity getNumerator() { 074 if (this.numerator == null) 075 if (Configuration.errorOnAutoCreate()) 076 throw new Error("Attempt to auto-create Ratio.numerator"); 077 else if (Configuration.doAutoCreate()) 078 this.numerator = new Quantity(); // cc 079 return this.numerator; 080 } 081 082 public boolean hasNumerator() { 083 return this.numerator != null && !this.numerator.isEmpty(); 084 } 085 086 /** 087 * @param value {@link #numerator} (The value of the numerator.) 088 */ 089 public Ratio setNumerator(Quantity value) { 090 this.numerator = value; 091 return this; 092 } 093 094 /** 095 * @return {@link #denominator} (The value of the denominator.) 096 */ 097 public Quantity getDenominator() { 098 if (this.denominator == null) 099 if (Configuration.errorOnAutoCreate()) 100 throw new Error("Attempt to auto-create Ratio.denominator"); 101 else if (Configuration.doAutoCreate()) 102 this.denominator = new Quantity(); // cc 103 return this.denominator; 104 } 105 106 public boolean hasDenominator() { 107 return this.denominator != null && !this.denominator.isEmpty(); 108 } 109 110 /** 111 * @param value {@link #denominator} (The value of the denominator.) 112 */ 113 public Ratio setDenominator(Quantity value) { 114 this.denominator = value; 115 return this; 116 } 117 118 protected void listChildren(List<Property> childrenList) { 119 super.listChildren(childrenList); 120 childrenList.add(new Property("numerator", "Quantity", "The value of the numerator.", 0, java.lang.Integer.MAX_VALUE, numerator)); 121 childrenList.add(new Property("denominator", "Quantity", "The value of the denominator.", 0, java.lang.Integer.MAX_VALUE, denominator)); 122 } 123 124 @Override 125 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 126 switch (hash) { 127 case 1747334793: /*numerator*/ return this.numerator == null ? new Base[0] : new Base[] {this.numerator}; // Quantity 128 case -1983274394: /*denominator*/ return this.denominator == null ? new Base[0] : new Base[] {this.denominator}; // Quantity 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 1747334793: // numerator 138 this.numerator = castToQuantity(value); // Quantity 139 break; 140 case -1983274394: // denominator 141 this.denominator = castToQuantity(value); // Quantity 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("numerator")) 151 this.numerator = castToQuantity(value); // Quantity 152 else if (name.equals("denominator")) 153 this.denominator = castToQuantity(value); // Quantity 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 1747334793: return getNumerator(); // Quantity 162 case -1983274394: return getDenominator(); // Quantity 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("numerator")) { 171 this.numerator = new Quantity(); 172 return this.numerator; 173 } 174 else if (name.equals("denominator")) { 175 this.denominator = new Quantity(); 176 return this.denominator; 177 } 178 else 179 return super.addChild(name); 180 } 181 182 public String fhirType() { 183 return "Ratio"; 184 185 } 186 187 public Ratio copy() { 188 Ratio dst = new Ratio(); 189 copyValues(dst); 190 dst.numerator = numerator == null ? null : numerator.copy(); 191 dst.denominator = denominator == null ? null : denominator.copy(); 192 return dst; 193 } 194 195 protected Ratio 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 Ratio)) 204 return false; 205 Ratio o = (Ratio) other; 206 return compareDeep(numerator, o.numerator, true) && compareDeep(denominator, o.denominator, true) 207 ; 208 } 209 210 @Override 211 public boolean equalsShallow(Base other) { 212 if (!super.equalsShallow(other)) 213 return false; 214 if (!(other instanceof Ratio)) 215 return false; 216 Ratio o = (Ratio) other; 217 return true; 218 } 219 220 public boolean isEmpty() { 221 return super.isEmpty() && (numerator == null || numerator.isEmpty()) && (denominator == null || denominator.isEmpty()) 222 ; 223 } 224 225 226} 227