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 * 
050 */
051@DatatypeDef(name="TranslatedString")
052public class TranslatedString extends LogicalBase implements ICompositeType {
053
054    /**
055     * 
056     */
057    @Child(name = "language", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=false)
058    @Description(shortDefinition="todo", formalDefinition="" )
059    protected CodeType language;
060
061    /**
062     * 
063     */
064    @Child(name = "value", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="todo", formalDefinition="" )
066    protected StringType value;
067
068    private static final long serialVersionUID = 499908337L;
069
070  /**
071   * Constructor
072   */
073    public TranslatedString() {
074      super();
075    }
076
077  /**
078   * Constructor
079   */
080    public TranslatedString(String language, String value) {
081      super();
082      this.setLanguage(language);
083      this.setValue(value);
084    }
085
086    /**
087     * @return {@link #language} (). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
088     */
089    public CodeType getLanguageElement() { 
090      if (this.language == null)
091        if (Configuration.errorOnAutoCreate())
092          throw new Error("Attempt to auto-create TranslatedString.language");
093        else if (Configuration.doAutoCreate())
094          this.language = new CodeType(); // bb
095      return this.language;
096    }
097
098    public boolean hasLanguageElement() { 
099      return this.language != null && !this.language.isEmpty();
100    }
101
102    public boolean hasLanguage() { 
103      return this.language != null && !this.language.isEmpty();
104    }
105
106    /**
107     * @param value {@link #language} (). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
108     */
109    public TranslatedString setLanguageElement(CodeType value) { 
110      this.language = value;
111      return this;
112    }
113
114    /**
115     * @return 
116     */
117    public String getLanguage() { 
118      return this.language == null ? null : this.language.getValue();
119    }
120
121    /**
122     * @param value 
123     */
124    public TranslatedString setLanguage(String value) { 
125        if (this.language == null)
126          this.language = new CodeType();
127        this.language.setValue(value);
128      return this;
129    }
130
131    /**
132     * @return {@link #value} (). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
133     */
134    public StringType getValueElement() { 
135      if (this.value == null)
136        if (Configuration.errorOnAutoCreate())
137          throw new Error("Attempt to auto-create TranslatedString.value");
138        else if (Configuration.doAutoCreate())
139          this.value = new StringType(); // bb
140      return this.value;
141    }
142
143    public boolean hasValueElement() { 
144      return this.value != null && !this.value.isEmpty();
145    }
146
147    public boolean hasValue() { 
148      return this.value != null && !this.value.isEmpty();
149    }
150
151    /**
152     * @param value {@link #value} (). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
153     */
154    public TranslatedString setValueElement(StringType value) { 
155      this.value = value;
156      return this;
157    }
158
159    /**
160     * @return 
161     */
162    public String getValue() { 
163      return this.value == null ? null : this.value.getValue();
164    }
165
166    /**
167     * @param value 
168     */
169    public TranslatedString setValue(String value) { 
170        if (this.value == null)
171          this.value = new StringType();
172        this.value.setValue(value);
173      return this;
174    }
175
176      protected void listChildren(List<Property> children) {
177        super.listChildren(children);
178        children.add(new Property("language", "code", "", 0, 1, language));
179        children.add(new Property("value", "string", "", 0, 1, value));
180      }
181
182      @Override
183      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
184        switch (_hash) {
185        case -1613589672: /*language*/  return new Property("language", "code", "", 0, 1, language);
186        case 111972721: /*value*/  return new Property("value", "string", "", 0, 1, value);
187        default: return super.getNamedProperty(_hash, _name, _checkValid);
188        }
189
190      }
191
192      @Override
193      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
194        switch (hash) {
195        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType
196        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType
197        default: return super.getProperty(hash, name, checkValid);
198        }
199
200      }
201
202      @Override
203      public Base setProperty(int hash, String name, Base value) throws FHIRException {
204        switch (hash) {
205        case -1613589672: // language
206          this.language = TypeConvertor.castToCode(value); // CodeType
207          return value;
208        case 111972721: // value
209          this.value = TypeConvertor.castToString(value); // StringType
210          return value;
211        default: return super.setProperty(hash, name, value);
212        }
213
214      }
215
216      @Override
217      public Base setProperty(String name, Base value) throws FHIRException {
218        if (name.equals("language")) {
219          this.language = TypeConvertor.castToCode(value); // CodeType
220        } else if (name.equals("value")) {
221          this.value = TypeConvertor.castToString(value); // StringType
222        } else
223          return super.setProperty(name, value);
224        return value;
225      }
226
227      @Override
228      public Base makeProperty(int hash, String name) throws FHIRException {
229        switch (hash) {
230        case -1613589672:  return getLanguageElement();
231        case 111972721:  return getValueElement();
232        default: return super.makeProperty(hash, name);
233        }
234
235      }
236
237      @Override
238      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
239        switch (hash) {
240        case -1613589672: /*language*/ return new String[] {"code"};
241        case 111972721: /*value*/ return new String[] {"string"};
242        default: return super.getTypesForProperty(hash, name);
243        }
244
245      }
246
247      @Override
248      public Base addChild(String name) throws FHIRException {
249        if (name.equals("language")) {
250          throw new FHIRException("Cannot call addChild on a singleton property TranslatedString.language");
251        }
252        else if (name.equals("value")) {
253          throw new FHIRException("Cannot call addChild on a singleton property TranslatedString.value");
254        }
255        else
256          return super.addChild(name);
257      }
258
259  public String fhirType() {
260    return "TranslatedString";
261
262  }
263
264      public TranslatedString copy() {
265        TranslatedString dst = new TranslatedString();
266        copyValues(dst);
267        return dst;
268      }
269
270      public void copyValues(TranslatedString dst) {
271        super.copyValues(dst);
272        dst.language = language == null ? null : language.copy();
273        dst.value = value == null ? null : value.copy();
274      }
275
276      protected TranslatedString typedCopy() {
277        return copy();
278      }
279
280      @Override
281      public boolean equalsDeep(Base other_) {
282        if (!super.equalsDeep(other_))
283          return false;
284        if (!(other_ instanceof TranslatedString))
285          return false;
286        TranslatedString o = (TranslatedString) other_;
287        return compareDeep(language, o.language, true) && compareDeep(value, o.value, true);
288      }
289
290      @Override
291      public boolean equalsShallow(Base other_) {
292        if (!super.equalsShallow(other_))
293          return false;
294        if (!(other_ instanceof TranslatedString))
295          return false;
296        TranslatedString o = (TranslatedString) other_;
297        return compareValues(language, o.language, true) && compareValues(value, o.value, true);
298      }
299
300      public boolean isEmpty() {
301        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(language, value);
302      }
303
304
305}
306