001package org.hl7.fhir.r5.model; 002 003 004/* 005 * #%L 006 * org.hl7.fhir.r5 007 * %% 008 * Copyright (C) 2014 - 2019 Health Level 7 009 * %% 010 * Licensed under the Apache License, Version 2.0 (the \"License\"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an \"AS IS\" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * #L% 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// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent 053 054import java.util.ArrayList; 055import java.util.Date; 056import java.util.List; 057import org.hl7.fhir.r5.model.Enumerations.*; 058import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; 059import org.hl7.fhir.exceptions.FHIRException; 060import org.hl7.fhir.instance.model.api.ICompositeType; 061import ca.uhn.fhir.model.api.annotation.Child; 062import ca.uhn.fhir.model.api.annotation.ChildOrder; 063import ca.uhn.fhir.model.api.annotation.DatatypeDef; 064import ca.uhn.fhir.model.api.annotation.Description; 065import ca.uhn.fhir.model.api.annotation.Block; 066 067/** 068 * Base StructureDefinition for Ratio Type: A relationship of two Quantity values - expressed as a numerator and a denominator. 069 */ 070@DatatypeDef(name="Ratio") 071public class Ratio extends DataType implements ICompositeType { 072 073 /** 074 * The value of the numerator. 075 */ 076 @Child(name = "numerator", type = {Quantity.class}, order=0, min=0, max=1, modifier=false, summary=true) 077 @Description(shortDefinition="Numerator value", formalDefinition="The value of the numerator." ) 078 protected Quantity numerator; 079 080 /** 081 * The value of the denominator. 082 */ 083 @Child(name = "denominator", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=true) 084 @Description(shortDefinition="Denominator value", formalDefinition="The value of the denominator." ) 085 protected Quantity denominator; 086 087 private static final long serialVersionUID = 479922563L; 088 089 /** 090 * Constructor 091 */ 092 public Ratio() { 093 super(); 094 } 095 096 /** 097 * @return {@link #numerator} (The value of the numerator.) 098 */ 099 public Quantity getNumerator() { 100 if (this.numerator == null) 101 if (Configuration.errorOnAutoCreate()) 102 throw new Error("Attempt to auto-create Ratio.numerator"); 103 else if (Configuration.doAutoCreate()) 104 this.numerator = new Quantity(); // cc 105 return this.numerator; 106 } 107 108 public boolean hasNumerator() { 109 return this.numerator != null && !this.numerator.isEmpty(); 110 } 111 112 /** 113 * @param value {@link #numerator} (The value of the numerator.) 114 */ 115 public Ratio setNumerator(Quantity value) { 116 this.numerator = value; 117 return this; 118 } 119 120 /** 121 * @return {@link #denominator} (The value of the denominator.) 122 */ 123 public Quantity getDenominator() { 124 if (this.denominator == null) 125 if (Configuration.errorOnAutoCreate()) 126 throw new Error("Attempt to auto-create Ratio.denominator"); 127 else if (Configuration.doAutoCreate()) 128 this.denominator = new Quantity(); // cc 129 return this.denominator; 130 } 131 132 public boolean hasDenominator() { 133 return this.denominator != null && !this.denominator.isEmpty(); 134 } 135 136 /** 137 * @param value {@link #denominator} (The value of the denominator.) 138 */ 139 public Ratio setDenominator(Quantity value) { 140 this.denominator = value; 141 return this; 142 } 143 144 protected void listChildren(List<Property> children) { 145 super.listChildren(children); 146 children.add(new Property("numerator", "Quantity", "The value of the numerator.", 0, 1, numerator)); 147 children.add(new Property("denominator", "Quantity", "The value of the denominator.", 0, 1, denominator)); 148 } 149 150 @Override 151 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 152 switch (_hash) { 153 case 1747334793: /*numerator*/ return new Property("numerator", "Quantity", "The value of the numerator.", 0, 1, numerator); 154 case -1983274394: /*denominator*/ return new Property("denominator", "Quantity", "The value of the denominator.", 0, 1, denominator); 155 default: return super.getNamedProperty(_hash, _name, _checkValid); 156 } 157 158 } 159 160 @Override 161 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 162 switch (hash) { 163 case 1747334793: /*numerator*/ return this.numerator == null ? new Base[0] : new Base[] {this.numerator}; // Quantity 164 case -1983274394: /*denominator*/ return this.denominator == null ? new Base[0] : new Base[] {this.denominator}; // Quantity 165 default: return super.getProperty(hash, name, checkValid); 166 } 167 168 } 169 170 @Override 171 public Base setProperty(int hash, String name, Base value) throws FHIRException { 172 switch (hash) { 173 case 1747334793: // numerator 174 this.numerator = TypeConvertor.castToQuantity(value); // Quantity 175 return value; 176 case -1983274394: // denominator 177 this.denominator = TypeConvertor.castToQuantity(value); // Quantity 178 return value; 179 default: return super.setProperty(hash, name, value); 180 } 181 182 } 183 184 @Override 185 public Base setProperty(String name, Base value) throws FHIRException { 186 if (name.equals("numerator")) { 187 this.numerator = TypeConvertor.castToQuantity(value); // Quantity 188 } else if (name.equals("denominator")) { 189 this.denominator = TypeConvertor.castToQuantity(value); // Quantity 190 } else 191 return super.setProperty(name, value); 192 return value; 193 } 194 195 @Override 196 public Base makeProperty(int hash, String name) throws FHIRException { 197 switch (hash) { 198 case 1747334793: return getNumerator(); 199 case -1983274394: return getDenominator(); 200 default: return super.makeProperty(hash, name); 201 } 202 203 } 204 205 @Override 206 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 207 switch (hash) { 208 case 1747334793: /*numerator*/ return new String[] {"Quantity"}; 209 case -1983274394: /*denominator*/ return new String[] {"Quantity"}; 210 default: return super.getTypesForProperty(hash, name); 211 } 212 213 } 214 215 @Override 216 public Base addChild(String name) throws FHIRException { 217 if (name.equals("numerator")) { 218 this.numerator = new Quantity(); 219 return this.numerator; 220 } 221 else if (name.equals("denominator")) { 222 this.denominator = new Quantity(); 223 return this.denominator; 224 } 225 else 226 return super.addChild(name); 227 } 228 229 public String fhirType() { 230 return "Ratio"; 231 232 } 233 234 public Ratio copy() { 235 Ratio dst = new Ratio(); 236 copyValues(dst); 237 return dst; 238 } 239 240 public void copyValues(Ratio dst) { 241 super.copyValues(dst); 242 dst.numerator = numerator == null ? null : numerator.copy(); 243 dst.denominator = denominator == null ? null : denominator.copy(); 244 } 245 246 protected Ratio typedCopy() { 247 return copy(); 248 } 249 250 @Override 251 public boolean equalsDeep(Base other_) { 252 if (!super.equalsDeep(other_)) 253 return false; 254 if (!(other_ instanceof Ratio)) 255 return false; 256 Ratio o = (Ratio) other_; 257 return compareDeep(numerator, o.numerator, true) && compareDeep(denominator, o.denominator, true) 258 ; 259 } 260 261 @Override 262 public boolean equalsShallow(Base other_) { 263 if (!super.equalsShallow(other_)) 264 return false; 265 if (!(other_ instanceof Ratio)) 266 return false; 267 Ratio o = (Ratio) other_; 268 return true; 269 } 270 271 public boolean isEmpty() { 272 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(numerator, denominator); 273 } 274 275 276} 277