001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0 036import java.util.List; 037 038import org.hl7.fhir.exceptions.FHIRException; 039import org.hl7.fhir.instance.model.api.ICompositeType; 040 041import ca.uhn.fhir.model.api.annotation.Child; 042import ca.uhn.fhir.model.api.annotation.DatatypeDef; 043import ca.uhn.fhir.model.api.annotation.Description; 044/** 045 * A set of ordered Quantities defined by a low and high limit. 046 */ 047@DatatypeDef(name="Range") 048public class Range extends Type implements ICompositeType { 049 050 /** 051 * The low limit. The boundary is inclusive. 052 */ 053 @Child(name = "low", type = {SimpleQuantity.class}, order=0, min=0, max=1, modifier=false, summary=true) 054 @Description(shortDefinition="Low limit", formalDefinition="The low limit. The boundary is inclusive." ) 055 protected SimpleQuantity low; 056 057 /** 058 * The high limit. The boundary is inclusive. 059 */ 060 @Child(name = "high", type = {SimpleQuantity.class}, order=1, min=0, max=1, modifier=false, summary=true) 061 @Description(shortDefinition="High limit", formalDefinition="The high limit. The boundary is inclusive." ) 062 protected SimpleQuantity high; 063 064 private static final long serialVersionUID = 1699187994L; 065 066 /** 067 * Constructor 068 */ 069 public Range() { 070 super(); 071 } 072 073 /** 074 * @return {@link #low} (The low limit. The boundary is inclusive.) 075 */ 076 public SimpleQuantity getLow() { 077 if (this.low == null) 078 if (Configuration.errorOnAutoCreate()) 079 throw new Error("Attempt to auto-create Range.low"); 080 else if (Configuration.doAutoCreate()) 081 this.low = new SimpleQuantity(); // cc 082 return this.low; 083 } 084 085 public boolean hasLow() { 086 return this.low != null && !this.low.isEmpty(); 087 } 088 089 /** 090 * @param value {@link #low} (The low limit. The boundary is inclusive.) 091 */ 092 public Range setLow(SimpleQuantity value) { 093 this.low = value; 094 return this; 095 } 096 097 /** 098 * @return {@link #high} (The high limit. The boundary is inclusive.) 099 */ 100 public SimpleQuantity getHigh() { 101 if (this.high == null) 102 if (Configuration.errorOnAutoCreate()) 103 throw new Error("Attempt to auto-create Range.high"); 104 else if (Configuration.doAutoCreate()) 105 this.high = new SimpleQuantity(); // cc 106 return this.high; 107 } 108 109 public boolean hasHigh() { 110 return this.high != null && !this.high.isEmpty(); 111 } 112 113 /** 114 * @param value {@link #high} (The high limit. The boundary is inclusive.) 115 */ 116 public Range setHigh(SimpleQuantity value) { 117 this.high = value; 118 return this; 119 } 120 121 protected void listChildren(List<Property> childrenList) { 122 super.listChildren(childrenList); 123 childrenList.add(new Property("low", "SimpleQuantity", "The low limit. The boundary is inclusive.", 0, java.lang.Integer.MAX_VALUE, low)); 124 childrenList.add(new Property("high", "SimpleQuantity", "The high limit. The boundary is inclusive.", 0, java.lang.Integer.MAX_VALUE, high)); 125 } 126 127 @Override 128 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 129 switch (hash) { 130 case 107348: /*low*/ return this.low == null ? new Base[0] : new Base[] {this.low}; // SimpleQuantity 131 case 3202466: /*high*/ return this.high == null ? new Base[0] : new Base[] {this.high}; // SimpleQuantity 132 default: return super.getProperty(hash, name, checkValid); 133 } 134 135 } 136 137 @Override 138 public void setProperty(int hash, String name, Base value) throws FHIRException { 139 switch (hash) { 140 case 107348: // low 141 this.low = castToSimpleQuantity(value); // SimpleQuantity 142 break; 143 case 3202466: // high 144 this.high = castToSimpleQuantity(value); // SimpleQuantity 145 break; 146 default: super.setProperty(hash, name, value); 147 } 148 149 } 150 151 @Override 152 public void setProperty(String name, Base value) throws FHIRException { 153 if (name.equals("low")) 154 this.low = castToSimpleQuantity(value); // SimpleQuantity 155 else if (name.equals("high")) 156 this.high = castToSimpleQuantity(value); // SimpleQuantity 157 else 158 super.setProperty(name, value); 159 } 160 161 @Override 162 public Base makeProperty(int hash, String name) throws FHIRException { 163 switch (hash) { 164 case 107348: return getLow(); // SimpleQuantity 165 case 3202466: return getHigh(); // SimpleQuantity 166 default: return super.makeProperty(hash, name); 167 } 168 169 } 170 171 @Override 172 public Base addChild(String name) throws FHIRException { 173 if (name.equals("low")) { 174 this.low = new SimpleQuantity(); 175 return this.low; 176 } 177 else if (name.equals("high")) { 178 this.high = new SimpleQuantity(); 179 return this.high; 180 } 181 else 182 return super.addChild(name); 183 } 184 185 public String fhirType() { 186 return "Range"; 187 188 } 189 190 public Range copy() { 191 Range dst = new Range(); 192 copyValues(dst); 193 dst.low = low == null ? null : low.copy(); 194 dst.high = high == null ? null : high.copy(); 195 return dst; 196 } 197 198 protected Range typedCopy() { 199 return copy(); 200 } 201 202 @Override 203 public boolean equalsDeep(Base other) { 204 if (!super.equalsDeep(other)) 205 return false; 206 if (!(other instanceof Range)) 207 return false; 208 Range o = (Range) other; 209 return compareDeep(low, o.low, true) && compareDeep(high, o.high, true); 210 } 211 212 @Override 213 public boolean equalsShallow(Base other) { 214 if (!super.equalsShallow(other)) 215 return false; 216 if (!(other instanceof Range)) 217 return false; 218 Range o = (Range) other; 219 return true; 220 } 221 222 public boolean isEmpty() { 223 return super.isEmpty() && (low == null || low.isEmpty()) && (high == null || high.isEmpty()) 224 ; 225 } 226 227 228}