001package org.hl7.fhir.r4.model; 002 003 004 005/* 006 Copyright (c) 2011+, HL7, Inc. 007 All rights reserved. 008 009 Redistribution and use in source and binary forms, with or without modification, 010 are permitted provided that the following conditions are met: 011 012 * Redistributions of source code must retain the above copyright notice, this 013 list of conditions and the following disclaimer. 014 * Redistributions in binary form must reproduce the above copyright notice, 015 this list of conditions and the following disclaimer in the documentation 016 and/or other materials provided with the distribution. 017 * Neither the name of HL7 nor the names of its contributors may be used to 018 endorse or promote products derived from this software without specific 019 prior written permission. 020 021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 024 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 025 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 026 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 027 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 028 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 029 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 030 POSSIBILITY OF SUCH DAMAGE. 031 032*/ 033 034 035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1 036 037import java.util.*; 038 039import ca.uhn.fhir.model.api.annotation.Child; 040import ca.uhn.fhir.model.api.annotation.ChildOrder; 041import ca.uhn.fhir.model.api.annotation.Description; 042import ca.uhn.fhir.model.api.annotation.DatatypeDef; 043import ca.uhn.fhir.model.api.annotation.Block; 044import org.hl7.fhir.instance.model.api.*; 045import org.hl7.fhir.exceptions.FHIRException; 046/** 047 * A set of ordered Quantities defined by a low and high limit. 048 */ 049@DatatypeDef(name="Range") 050public class Range extends Type implements ICompositeType { 051 052 /** 053 * The low limit. The boundary is inclusive. 054 */ 055 @Child(name = "low", type = {Quantity.class}, order=0, min=0, max=1, modifier=false, summary=true) 056 @Description(shortDefinition="Low limit", formalDefinition="The low limit. The boundary is inclusive." ) 057 protected Quantity low; 058 059 /** 060 * The high limit. The boundary is inclusive. 061 */ 062 @Child(name = "high", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=true) 063 @Description(shortDefinition="High limit", formalDefinition="The high limit. The boundary is inclusive." ) 064 protected Quantity high; 065 066 private static final long serialVersionUID = -474933350L; 067 068 /** 069 * Constructor 070 */ 071 public Range() { 072 super(); 073 } 074 075 /** 076 * @return {@link #low} (The low limit. The boundary is inclusive.) 077 */ 078 public Quantity getLow() { 079 if (this.low == null) 080 if (Configuration.errorOnAutoCreate()) 081 throw new Error("Attempt to auto-create Range.low"); 082 else if (Configuration.doAutoCreate()) 083 this.low = new Quantity(); // cc 084 return this.low; 085 } 086 087 public boolean hasLow() { 088 return this.low != null && !this.low.isEmpty(); 089 } 090 091 /** 092 * @param value {@link #low} (The low limit. The boundary is inclusive.) 093 */ 094 public Range setLow(Quantity value) { 095 this.low = value; 096 return this; 097 } 098 099 /** 100 * @return {@link #high} (The high limit. The boundary is inclusive.) 101 */ 102 public Quantity getHigh() { 103 if (this.high == null) 104 if (Configuration.errorOnAutoCreate()) 105 throw new Error("Attempt to auto-create Range.high"); 106 else if (Configuration.doAutoCreate()) 107 this.high = new Quantity(); // cc 108 return this.high; 109 } 110 111 public boolean hasHigh() { 112 return this.high != null && !this.high.isEmpty(); 113 } 114 115 /** 116 * @param value {@link #high} (The high limit. The boundary is inclusive.) 117 */ 118 public Range setHigh(Quantity value) { 119 this.high = value; 120 return this; 121 } 122 123 protected void listChildren(List<Property> children) { 124 super.listChildren(children); 125 children.add(new Property("low", "SimpleQuantity", "The low limit. The boundary is inclusive.", 0, 1, low)); 126 children.add(new Property("high", "SimpleQuantity", "The high limit. The boundary is inclusive.", 0, 1, high)); 127 } 128 129 @Override 130 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 131 switch (_hash) { 132 case 107348: /*low*/ return new Property("low", "SimpleQuantity", "The low limit. The boundary is inclusive.", 0, 1, low); 133 case 3202466: /*high*/ return new Property("high", "SimpleQuantity", "The high limit. The boundary is inclusive.", 0, 1, high); 134 default: return super.getNamedProperty(_hash, _name, _checkValid); 135 } 136 137 } 138 139 @Override 140 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 141 switch (hash) { 142 case 107348: /*low*/ return this.low == null ? new Base[0] : new Base[] {this.low}; // Quantity 143 case 3202466: /*high*/ return this.high == null ? new Base[0] : new Base[] {this.high}; // Quantity 144 default: return super.getProperty(hash, name, checkValid); 145 } 146 147 } 148 149 @Override 150 public Base setProperty(int hash, String name, Base value) throws FHIRException { 151 switch (hash) { 152 case 107348: // low 153 this.low = castToQuantity(value); // Quantity 154 return value; 155 case 3202466: // high 156 this.high = castToQuantity(value); // Quantity 157 return value; 158 default: return super.setProperty(hash, name, value); 159 } 160 161 } 162 163 @Override 164 public Base setProperty(String name, Base value) throws FHIRException { 165 if (name.equals("low")) { 166 this.low = castToQuantity(value); // Quantity 167 } else if (name.equals("high")) { 168 this.high = castToQuantity(value); // Quantity 169 } else 170 return super.setProperty(name, value); 171 return value; 172 } 173 174 @Override 175 public Base makeProperty(int hash, String name) throws FHIRException { 176 switch (hash) { 177 case 107348: return getLow(); 178 case 3202466: return getHigh(); 179 default: return super.makeProperty(hash, name); 180 } 181 182 } 183 184 @Override 185 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 186 switch (hash) { 187 case 107348: /*low*/ return new String[] {"SimpleQuantity"}; 188 case 3202466: /*high*/ return new String[] {"SimpleQuantity"}; 189 default: return super.getTypesForProperty(hash, name); 190 } 191 192 } 193 194 @Override 195 public Base addChild(String name) throws FHIRException { 196 if (name.equals("low")) { 197 this.low = new Quantity(); 198 return this.low; 199 } 200 else if (name.equals("high")) { 201 this.high = new Quantity(); 202 return this.high; 203 } 204 else 205 return super.addChild(name); 206 } 207 208 public String fhirType() { 209 return "Range"; 210 211 } 212 213 public Range copy() { 214 Range dst = new Range(); 215 copyValues(dst); 216 return dst; 217 } 218 219 public void copyValues(Range dst) { 220 super.copyValues(dst); 221 dst.low = low == null ? null : low.copy(); 222 dst.high = high == null ? null : high.copy(); 223 } 224 225 protected Range typedCopy() { 226 return copy(); 227 } 228 229 @Override 230 public boolean equalsDeep(Base other_) { 231 if (!super.equalsDeep(other_)) 232 return false; 233 if (!(other_ instanceof Range)) 234 return false; 235 Range o = (Range) other_; 236 return compareDeep(low, o.low, true) && compareDeep(high, o.high, true); 237 } 238 239 @Override 240 public boolean equalsShallow(Base other_) { 241 if (!super.equalsShallow(other_)) 242 return false; 243 if (!(other_ instanceof Range)) 244 return false; 245 Range o = (Range) other_; 246 return true; 247 } 248 249 public boolean isEmpty() { 250 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(low, high); 251 } 252 253 254}