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 Range Type: A set of ordered Quantities defined by a low and high limit. 069 */ 070@DatatypeDef(name="Range") 071public class Range extends DataType implements ICompositeType { 072 073 /** 074 * The low limit. The boundary is inclusive. 075 */ 076 @Child(name = "low", type = {Quantity.class}, order=0, min=0, max=1, modifier=false, summary=true) 077 @Description(shortDefinition="Low limit", formalDefinition="The low limit. The boundary is inclusive." ) 078 protected Quantity low; 079 080 /** 081 * The high limit. The boundary is inclusive. 082 */ 083 @Child(name = "high", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=true) 084 @Description(shortDefinition="High limit", formalDefinition="The high limit. The boundary is inclusive." ) 085 protected Quantity high; 086 087 private static final long serialVersionUID = -474933350L; 088 089 /** 090 * Constructor 091 */ 092 public Range() { 093 super(); 094 } 095 096 /** 097 * @return {@link #low} (The low limit. The boundary is inclusive.) 098 */ 099 public Quantity getLow() { 100 if (this.low == null) 101 if (Configuration.errorOnAutoCreate()) 102 throw new Error("Attempt to auto-create Range.low"); 103 else if (Configuration.doAutoCreate()) 104 this.low = new Quantity(); // cc 105 return this.low; 106 } 107 108 public boolean hasLow() { 109 return this.low != null && !this.low.isEmpty(); 110 } 111 112 /** 113 * @param value {@link #low} (The low limit. The boundary is inclusive.) 114 */ 115 public Range setLow(Quantity value) { 116 this.low = value; 117 return this; 118 } 119 120 /** 121 * @return {@link #high} (The high limit. The boundary is inclusive.) 122 */ 123 public Quantity getHigh() { 124 if (this.high == null) 125 if (Configuration.errorOnAutoCreate()) 126 throw new Error("Attempt to auto-create Range.high"); 127 else if (Configuration.doAutoCreate()) 128 this.high = new Quantity(); // cc 129 return this.high; 130 } 131 132 public boolean hasHigh() { 133 return this.high != null && !this.high.isEmpty(); 134 } 135 136 /** 137 * @param value {@link #high} (The high limit. The boundary is inclusive.) 138 */ 139 public Range setHigh(Quantity value) { 140 this.high = value; 141 return this; 142 } 143 144 protected void listChildren(List<Property> children) { 145 super.listChildren(children); 146 children.add(new Property("low", "Quantity", "The low limit. The boundary is inclusive.", 0, 1, low)); 147 children.add(new Property("high", "Quantity", "The high limit. The boundary is inclusive.", 0, 1, high)); 148 } 149 150 @Override 151 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 152 switch (_hash) { 153 case 107348: /*low*/ return new Property("low", "Quantity", "The low limit. The boundary is inclusive.", 0, 1, low); 154 case 3202466: /*high*/ return new Property("high", "Quantity", "The high limit. The boundary is inclusive.", 0, 1, high); 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 107348: /*low*/ return this.low == null ? new Base[0] : new Base[] {this.low}; // Quantity 164 case 3202466: /*high*/ return this.high == null ? new Base[0] : new Base[] {this.high}; // 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 107348: // low 174 this.low = TypeConvertor.castToQuantity(value); // Quantity 175 return value; 176 case 3202466: // high 177 this.high = 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("low")) { 187 this.low = TypeConvertor.castToQuantity(value); // Quantity 188 } else if (name.equals("high")) { 189 this.high = 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 107348: return getLow(); 199 case 3202466: return getHigh(); 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 107348: /*low*/ return new String[] {"Quantity"}; 209 case 3202466: /*high*/ 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("low")) { 218 this.low = new Quantity(); 219 return this.low; 220 } 221 else if (name.equals("high")) { 222 this.high = new Quantity(); 223 return this.high; 224 } 225 else 226 return super.addChild(name); 227 } 228 229 public String fhirType() { 230 return "Range"; 231 232 } 233 234 public Range copy() { 235 Range dst = new Range(); 236 copyValues(dst); 237 return dst; 238 } 239 240 public void copyValues(Range dst) { 241 super.copyValues(dst); 242 dst.low = low == null ? null : low.copy(); 243 dst.high = high == null ? null : high.copy(); 244 } 245 246 protected Range 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 Range)) 255 return false; 256 Range o = (Range) other_; 257 return compareDeep(low, o.low, true) && compareDeep(high, o.high, true); 258 } 259 260 @Override 261 public boolean equalsShallow(Base other_) { 262 if (!super.equalsShallow(other_)) 263 return false; 264 if (!(other_ instanceof Range)) 265 return false; 266 Range o = (Range) other_; 267 return true; 268 } 269 270 public boolean isEmpty() { 271 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(low, high); 272 } 273 274 275} 276