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