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