
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 * A reference to an object which structurally conforms to the Universal Resource Identifier (URI) RFC-3986 standard. The reference is contained in the value attribute, which is a String. So-called 'plain-text URIs' that contain RFC-3986 forbidden characters such as spaces etc, are allowed on the basis that they need to be RFC-3986 encoded prior to use in e.g. REST APIs or other contexts relying on machine-level conformance. 050 */ 051@DatatypeDef(name="DV_URI") 052public class DV_URI extends DATA_VALUE implements ICompositeType { 053 054 /** 055 * Value of URI as a String. 'Plain-text' URIs are allowed, enabling better readability, but must be RFC-3986 encoded in use. 056 */ 057 @Child(name = "value", type = {UriType.class}, order=0, min=1, max=1, modifier=false, summary=false) 058 @Description(shortDefinition="Value of URI as a String, must be RFC-3986 encoded in use", formalDefinition="Value of URI as a String. 'Plain-text' URIs are allowed, enabling better readability, but must be RFC-3986 encoded in use." ) 059 protected UriType value; 060 061 private static final long serialVersionUID = 702163571L; 062 063 /** 064 * Constructor 065 */ 066 public DV_URI() { 067 super(); 068 } 069 070 /** 071 * Constructor 072 */ 073 public DV_URI(String value) { 074 super(); 075 this.setValue(value); 076 } 077 078 /** 079 * @return {@link #value} (Value of URI as a String. 'Plain-text' URIs are allowed, enabling better readability, but must be RFC-3986 encoded in use.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value 080 */ 081 public UriType getValueElement() { 082 if (this.value == null) 083 if (Configuration.errorOnAutoCreate()) 084 throw new Error("Attempt to auto-create DV_URI.value"); 085 else if (Configuration.doAutoCreate()) 086 this.value = new UriType(); // 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} (Value of URI as a String. 'Plain-text' URIs are allowed, enabling better readability, but must be RFC-3986 encoded in use.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value 100 */ 101 public DV_URI setValueElement(UriType value) { 102 this.value = value; 103 return this; 104 } 105 106 /** 107 * @return Value of URI as a String. 'Plain-text' URIs are allowed, enabling better readability, but must be RFC-3986 encoded in use. 108 */ 109 public String getValue() { 110 return this.value == null ? null : this.value.getValue(); 111 } 112 113 /** 114 * @param value Value of URI as a String. 'Plain-text' URIs are allowed, enabling better readability, but must be RFC-3986 encoded in use. 115 */ 116 public DV_URI setValue(String value) { 117 if (this.value == null) 118 this.value = new UriType(); 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", "uri", "Value of URI as a String. 'Plain-text' URIs are allowed, enabling better readability, but must be RFC-3986 encoded in use.", 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", "uri", "Value of URI as a String. 'Plain-text' URIs are allowed, enabling better readability, but must be RFC-3986 encoded in use.", 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}; // UriType 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.castToUri(value); // UriType 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.castToUri(value); // UriType 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[] {"uri"}; 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 DV_URI.value"); 188 } 189 else 190 return super.addChild(name); 191 } 192 193 public String fhirType() { 194 return "DV_URI"; 195 196 } 197 198 public DV_URI copy() { 199 DV_URI dst = new DV_URI(); 200 copyValues(dst); 201 return dst; 202 } 203 204 public void copyValues(DV_URI dst) { 205 super.copyValues(dst); 206 dst.value = value == null ? null : value.copy(); 207 } 208 209 protected DV_URI typedCopy() { 210 return copy(); 211 } 212 213 @Override 214 public boolean equalsDeep(Base other_) { 215 if (!super.equalsDeep(other_)) 216 return false; 217 if (!(other_ instanceof DV_URI)) 218 return false; 219 DV_URI o = (DV_URI) other_; 220 return compareDeep(value, o.value, true); 221 } 222 223 @Override 224 public boolean equalsShallow(Base other_) { 225 if (!super.equalsShallow(other_)) 226 return false; 227 if (!(other_ instanceof DV_URI)) 228 return false; 229 DV_URI o = (DV_URI) other_; 230 return compareValues(value, o.value, true); 231 } 232 233 public boolean isEmpty() { 234 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(value); 235 } 236 237 238} 239