
001package org.hl7.fhir.r5.openehr; 002 003 004/* 005 Copyright (c) 2011+, HL7, Inc. 006 All rights reserved. 007 008 Redistribution and use in source and binary forms, with or without modification, \ 009 are permitted provided that the following conditions are met: 010 011 * Redistributions of source code must retain the above copyright notice, this \ 012 list of conditions and the following disclaimer. 013 * Redistributions in binary form must reproduce the above copyright notice, \ 014 this list of conditions and the following disclaimer in the documentation \ 015 and/or other materials provided with the distribution. 016 * Neither the name of HL7 nor the names of its contributors may be used to 017 endorse or promote products derived from this software without specific 018 prior written permission. 019 020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \ 021 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \ 022 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \ 023 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \ 024 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \ 025 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \ 026 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \ 027 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \ 028 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \ 029 POSSIBILITY OF SUCH DAMAGE. 030 */ 031 032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0 033 034import java.util.ArrayList; 035import java.util.Date; 036import java.util.List; 037import org.hl7.fhir.utilities.Utilities; 038import org.hl7.fhir.r5.openehr.Enumerations.*; 039import org.hl7.fhir.exceptions.FHIRException; 040import org.hl7.fhir.r5.model.*; 041import org.hl7.fhir.instance.model.api.ICompositeType; 042import ca.uhn.fhir.model.api.annotation.Child; 043import ca.uhn.fhir.model.api.annotation.ChildOrder; 044import ca.uhn.fhir.model.api.annotation.DatatypeDef; 045import ca.uhn.fhir.model.api.annotation.Description; 046import ca.uhn.fhir.model.api.annotation.Block; 047 048/** 049 * Abstract parent of classes representing unique identifiers which identify information entities in a durable way. UIDs only ever identify one IE in time or space and are never re-used. 050 */ 051@DatatypeDef(name="UID") 052public abstract class UID extends LogicalBase implements ICompositeType { 053 054 /** 055 * The value of the id. 056 */ 057 @Child(name = "value", type = {StringType.class}, order=0, min=1, max=1, modifier=false, summary=false) 058 @Description(shortDefinition="The value of the id", formalDefinition="The value of the id." ) 059 protected StringType value; 060 061 private static final long serialVersionUID = -301439478L; 062 063 /** 064 * Constructor 065 */ 066 public UID() { 067 super(); 068 } 069 070 /** 071 * Constructor 072 */ 073 public UID(String value) { 074 super(); 075 this.setValue(value); 076 } 077 078 /** 079 * @return {@link #value} (The value of the id.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value 080 */ 081 public StringType getValueElement() { 082 if (this.value == null) 083 if (Configuration.errorOnAutoCreate()) 084 throw new Error("Attempt to auto-create UID.value"); 085 else if (Configuration.doAutoCreate()) 086 this.value = new StringType(); // bb 087 return this.value; 088 } 089 090 public boolean hasValueElement() { 091 return this.value != null && !this.value.isEmpty(); 092 } 093 094 public boolean hasValue() { 095 return this.value != null && !this.value.isEmpty(); 096 } 097 098 /** 099 * @param value {@link #value} (The value of the id.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value 100 */ 101 public UID setValueElement(StringType value) { 102 this.value = value; 103 return this; 104 } 105 106 /** 107 * @return The value of the id. 108 */ 109 public String getValue() { 110 return this.value == null ? null : this.value.getValue(); 111 } 112 113 /** 114 * @param value The value of the id. 115 */ 116 public UID setValue(String value) { 117 if (this.value == null) 118 this.value = new StringType(); 119 this.value.setValue(value); 120 return this; 121 } 122 123 protected void listChildren(List<Property> children) { 124 super.listChildren(children); 125 children.add(new Property("value", "string", "The value of the id.", 0, 1, value)); 126 } 127 128 @Override 129 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 130 switch (_hash) { 131 case 111972721: /*value*/ return new Property("value", "string", "The value of the id.", 0, 1, value); 132 default: return super.getNamedProperty(_hash, _name, _checkValid); 133 } 134 135 } 136 137 @Override 138 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 139 switch (hash) { 140 case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType 141 default: return super.getProperty(hash, name, checkValid); 142 } 143 144 } 145 146 @Override 147 public Base setProperty(int hash, String name, Base value) throws FHIRException { 148 switch (hash) { 149 case 111972721: // value 150 this.value = TypeConvertor.castToString(value); // StringType 151 return value; 152 default: return super.setProperty(hash, name, value); 153 } 154 155 } 156 157 @Override 158 public Base setProperty(String name, Base value) throws FHIRException { 159 if (name.equals("value")) { 160 this.value = TypeConvertor.castToString(value); // StringType 161 } else 162 return super.setProperty(name, value); 163 return value; 164 } 165 166 @Override 167 public Base makeProperty(int hash, String name) throws FHIRException { 168 switch (hash) { 169 case 111972721: return getValueElement(); 170 default: return super.makeProperty(hash, name); 171 } 172 173 } 174 175 @Override 176 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 177 switch (hash) { 178 case 111972721: /*value*/ return new String[] {"string"}; 179 default: return super.getTypesForProperty(hash, name); 180 } 181 182 } 183 184 @Override 185 public Base addChild(String name) throws FHIRException { 186 if (name.equals("value")) { 187 throw new FHIRException("Cannot call addChild on a singleton property UID.value"); 188 } 189 else 190 return super.addChild(name); 191 } 192 193 public String fhirType() { 194 return "UID"; 195 196 } 197 198 public abstract UID copy(); 199 200 public void copyValues(UID dst) { 201 super.copyValues(dst); 202 dst.value = value == null ? null : value.copy(); 203 } 204 205 @Override 206 public boolean equalsDeep(Base other_) { 207 if (!super.equalsDeep(other_)) 208 return false; 209 if (!(other_ instanceof UID)) 210 return false; 211 UID o = (UID) other_; 212 return compareDeep(value, o.value, true); 213 } 214 215 @Override 216 public boolean equalsShallow(Base other_) { 217 if (!super.equalsShallow(other_)) 218 return false; 219 if (!(other_ instanceof UID)) 220 return false; 221 UID o = (UID) other_; 222 return compareValues(value, o.value, true); 223 } 224 225 public boolean isEmpty() { 226 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(value); 227 } 228 229 230} 231