001package org.hl7.fhir.dstu2.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.dstu2
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 Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
054import java.util.ArrayList;
055import java.util.List;
056
057import ca.uhn.fhir.model.api.annotation.Block;
058import ca.uhn.fhir.model.api.annotation.Child;
059import ca.uhn.fhir.model.api.annotation.Description;
060import ca.uhn.fhir.model.api.annotation.ResourceDef;
061import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
062import org.hl7.fhir.instance.model.api.IBaseParameters;
063import org.hl7.fhir.exceptions.FHIRException;
064/**
065 * This special resource type is used to represent an operation request and response (operations.html). It has no other use, and there is no RESTful endpoint associated with it.
066 */
067@ResourceDef(name="Parameters", profile="http://hl7.org/fhir/Profile/Parameters")
068public class Parameters extends Resource implements IBaseParameters {
069
070    @Block()
071    public static class ParametersParameterComponent extends BackboneElement implements IBaseBackboneElement {
072        /**
073         * The name of the parameter (reference to the operation definition).
074         */
075        @Child(name = "name", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
076        @Description(shortDefinition="Name from the definition", formalDefinition="The name of the parameter (reference to the operation definition)." )
077        protected StringType name;
078
079        /**
080         * If the parameter is a data type.
081         */
082        @Child(name = "value", type = {}, order=2, min=0, max=1, modifier=false, summary=false)
083        @Description(shortDefinition="If parameter is a data type", formalDefinition="If the parameter is a data type." )
084        protected org.hl7.fhir.dstu2.model.Type value;
085
086        /**
087         * If the parameter is a whole resource.
088         */
089        @Child(name = "resource", type = {Resource.class}, order=3, min=0, max=1, modifier=false, summary=false)
090        @Description(shortDefinition="If parameter is a whole resource", formalDefinition="If the parameter is a whole resource." )
091        protected Resource resource;
092
093        /**
094         * A named part of a parameter. In many implementation context, a set of named parts is known as a "Tuple".
095         */
096        @Child(name = "part", type = {ParametersParameterComponent.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
097        @Description(shortDefinition="Named part of a parameter (e.g. Tuple)", formalDefinition="A named part of a parameter. In many implementation context, a set of named parts is known as a \"Tuple\"." )
098        protected List<ParametersParameterComponent> part;
099
100        private static final long serialVersionUID = -198518915L;
101
102    /*
103     * Constructor
104     */
105      public ParametersParameterComponent() {
106        super();
107      }
108
109    /*
110     * Constructor
111     */
112      public ParametersParameterComponent(StringType name) {
113        super();
114        this.name = name;
115      }
116
117        /**
118         * @return {@link #name} (The name of the parameter (reference to the operation definition).). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
119         */
120        public StringType getNameElement() { 
121          if (this.name == null)
122            if (Configuration.errorOnAutoCreate())
123              throw new Error("Attempt to auto-create ParametersParameterComponent.name");
124            else if (Configuration.doAutoCreate())
125              this.name = new StringType(); // bb
126          return this.name;
127        }
128
129        public boolean hasNameElement() { 
130          return this.name != null && !this.name.isEmpty();
131        }
132
133        public boolean hasName() { 
134          return this.name != null && !this.name.isEmpty();
135        }
136
137        /**
138         * @param value {@link #name} (The name of the parameter (reference to the operation definition).). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
139         */
140        public ParametersParameterComponent setNameElement(StringType value) { 
141          this.name = value;
142          return this;
143        }
144
145        /**
146         * @return The name of the parameter (reference to the operation definition).
147         */
148        public String getName() { 
149          return this.name == null ? null : this.name.getValue();
150        }
151
152        /**
153         * @param value The name of the parameter (reference to the operation definition).
154         */
155        public ParametersParameterComponent setName(String value) { 
156            if (this.name == null)
157              this.name = new StringType();
158            this.name.setValue(value);
159          return this;
160        }
161
162        /**
163         * @return {@link #value} (If the parameter is a data type.)
164         */
165        public org.hl7.fhir.dstu2.model.Type getValue() { 
166          return this.value;
167        }
168
169        public boolean hasValue() { 
170          return this.value != null && !this.value.isEmpty();
171        }
172
173        /**
174         * @param value {@link #value} (If the parameter is a data type.)
175         */
176        public ParametersParameterComponent setValue(org.hl7.fhir.dstu2.model.Type value) { 
177          this.value = value;
178          return this;
179        }
180
181        /**
182         * @return {@link #resource} (If the parameter is a whole resource.)
183         */
184        public Resource getResource() { 
185          return this.resource;
186        }
187
188        public boolean hasResource() { 
189          return this.resource != null && !this.resource.isEmpty();
190        }
191
192        /**
193         * @param value {@link #resource} (If the parameter is a whole resource.)
194         */
195        public ParametersParameterComponent setResource(Resource value) { 
196          this.resource = value;
197          return this;
198        }
199
200        /**
201         * @return {@link #part} (A named part of a parameter. In many implementation context, a set of named parts is known as a "Tuple".)
202         */
203        public List<ParametersParameterComponent> getPart() { 
204          if (this.part == null)
205            this.part = new ArrayList<ParametersParameterComponent>();
206          return this.part;
207        }
208
209        public boolean hasPart() { 
210          if (this.part == null)
211            return false;
212          for (ParametersParameterComponent item : this.part)
213            if (!item.isEmpty())
214              return true;
215          return false;
216        }
217
218        /**
219         * @return {@link #part} (A named part of a parameter. In many implementation context, a set of named parts is known as a "Tuple".)
220         */
221    // syntactic sugar
222        public ParametersParameterComponent addPart() { //3
223          ParametersParameterComponent t = new ParametersParameterComponent();
224          if (this.part == null)
225            this.part = new ArrayList<ParametersParameterComponent>();
226          this.part.add(t);
227          return t;
228        }
229
230    // syntactic sugar
231        public ParametersParameterComponent addPart(ParametersParameterComponent t) { //3
232          if (t == null)
233            return this;
234          if (this.part == null)
235            this.part = new ArrayList<ParametersParameterComponent>();
236          this.part.add(t);
237          return this;
238        }
239
240        protected void listChildren(List<Property> childrenList) {
241          super.listChildren(childrenList);
242          childrenList.add(new Property("name", "string", "The name of the parameter (reference to the operation definition).", 0, java.lang.Integer.MAX_VALUE, name));
243          childrenList.add(new Property("value[x]", "*", "If the parameter is a data type.", 0, java.lang.Integer.MAX_VALUE, value));
244          childrenList.add(new Property("resource", "Resource", "If the parameter is a whole resource.", 0, java.lang.Integer.MAX_VALUE, resource));
245          childrenList.add(new Property("part", "@Parameters.parameter", "A named part of a parameter. In many implementation context, a set of named parts is known as a \"Tuple\".", 0, java.lang.Integer.MAX_VALUE, part));
246        }
247
248      @Override
249      public void setProperty(String name, Base value) throws FHIRException {
250        if (name.equals("name"))
251          this.name = castToString(value); // StringType
252        else if (name.equals("value[x]"))
253          this.value = (org.hl7.fhir.dstu2.model.Type) value; // org.hl7.fhir.dstu2.model.Type
254        else if (name.equals("resource"))
255          this.resource = castToResource(value); // Resource
256        else if (name.equals("part"))
257          this.getPart().add((ParametersParameterComponent) value);
258        else
259          super.setProperty(name, value);
260      }
261
262      @Override
263      public Base addChild(String name) throws FHIRException {
264        if (name.equals("name")) {
265          throw new FHIRException("Cannot call addChild on a primitive type Parameters.name");
266        }
267        else if (name.equals("valueBoolean")) {
268          this.value = new BooleanType();
269          return this.value;
270        }
271        else if (name.equals("valueInteger")) {
272          this.value = new IntegerType();
273          return this.value;
274        }
275        else if (name.equals("valueDecimal")) {
276          this.value = new DecimalType();
277          return this.value;
278        }
279        else if (name.equals("valueBase64Binary")) {
280          this.value = new Base64BinaryType();
281          return this.value;
282        }
283        else if (name.equals("valueInstant")) {
284          this.value = new InstantType();
285          return this.value;
286        }
287        else if (name.equals("valueString")) {
288          this.value = new StringType();
289          return this.value;
290        }
291        else if (name.equals("valueUri")) {
292          this.value = new UriType();
293          return this.value;
294        }
295        else if (name.equals("valueDate")) {
296          this.value = new DateType();
297          return this.value;
298        }
299        else if (name.equals("valueDateTime")) {
300          this.value = new DateTimeType();
301          return this.value;
302        }
303        else if (name.equals("valueTime")) {
304          this.value = new TimeType();
305          return this.value;
306        }
307        else if (name.equals("valueCode")) {
308          this.value = new CodeType();
309          return this.value;
310        }
311        else if (name.equals("valueOid")) {
312          this.value = new OidType();
313          return this.value;
314        }
315        else if (name.equals("valueId")) {
316          this.value = new IdType();
317          return this.value;
318        }
319        else if (name.equals("valueUnsignedInt")) {
320          this.value = new UnsignedIntType();
321          return this.value;
322        }
323        else if (name.equals("valuePositiveInt")) {
324          this.value = new PositiveIntType();
325          return this.value;
326        }
327        else if (name.equals("valueMarkdown")) {
328          this.value = new MarkdownType();
329          return this.value;
330        }
331        else if (name.equals("valueAnnotation")) {
332          this.value = new Annotation();
333          return this.value;
334        }
335        else if (name.equals("valueAttachment")) {
336          this.value = new Attachment();
337          return this.value;
338        }
339        else if (name.equals("valueIdentifier")) {
340          this.value = new Identifier();
341          return this.value;
342        }
343        else if (name.equals("valueCodeableConcept")) {
344          this.value = new CodeableConcept();
345          return this.value;
346        }
347        else if (name.equals("valueCoding")) {
348          this.value = new Coding();
349          return this.value;
350        }
351        else if (name.equals("valueQuantity")) {
352          this.value = new Quantity();
353          return this.value;
354        }
355        else if (name.equals("valueRange")) {
356          this.value = new Range();
357          return this.value;
358        }
359        else if (name.equals("valuePeriod")) {
360          this.value = new Period();
361          return this.value;
362        }
363        else if (name.equals("valueRatio")) {
364          this.value = new Ratio();
365          return this.value;
366        }
367        else if (name.equals("valueSampledData")) {
368          this.value = new SampledData();
369          return this.value;
370        }
371        else if (name.equals("valueSignature")) {
372          this.value = new Signature();
373          return this.value;
374        }
375        else if (name.equals("valueHumanName")) {
376          this.value = new HumanName();
377          return this.value;
378        }
379        else if (name.equals("valueAddress")) {
380          this.value = new Address();
381          return this.value;
382        }
383        else if (name.equals("valueContactPoint")) {
384          this.value = new ContactPoint();
385          return this.value;
386        }
387        else if (name.equals("valueTiming")) {
388          this.value = new Timing();
389          return this.value;
390        }
391        else if (name.equals("valueReference")) {
392          this.value = new Reference();
393          return this.value;
394        }
395        else if (name.equals("valueMeta")) {
396          this.value = new Meta();
397          return this.value;
398        }
399        else if (name.equals("resource")) {
400          throw new FHIRException("Cannot call addChild on an abstract type Parameters.resource");
401        }
402        else if (name.equals("part")) {
403          return addPart();
404        }
405        else
406          return super.addChild(name);
407      }
408
409      public ParametersParameterComponent copy() {
410        ParametersParameterComponent dst = new ParametersParameterComponent();
411        copyValues(dst);
412        dst.name = name == null ? null : name.copy();
413        dst.value = value == null ? null : value.copy();
414        dst.resource = resource == null ? null : resource.copy();
415        if (part != null) {
416          dst.part = new ArrayList<ParametersParameterComponent>();
417          for (ParametersParameterComponent i : part)
418            dst.part.add(i.copy());
419        };
420        return dst;
421      }
422
423      @Override
424      public boolean equalsDeep(Base other) {
425        if (!super.equalsDeep(other))
426          return false;
427        if (!(other instanceof ParametersParameterComponent))
428          return false;
429        ParametersParameterComponent o = (ParametersParameterComponent) other;
430        return compareDeep(name, o.name, true) && compareDeep(value, o.value, true) && compareDeep(resource, o.resource, true)
431           && compareDeep(part, o.part, true);
432      }
433
434      @Override
435      public boolean equalsShallow(Base other) {
436        if (!super.equalsShallow(other))
437          return false;
438        if (!(other instanceof ParametersParameterComponent))
439          return false;
440        ParametersParameterComponent o = (ParametersParameterComponent) other;
441        return compareValues(name, o.name, true);
442      }
443
444      public boolean isEmpty() {
445        return super.isEmpty() && (name == null || name.isEmpty()) && (value == null || value.isEmpty())
446           && (resource == null || resource.isEmpty()) && (part == null || part.isEmpty());
447      }
448
449  public String fhirType() {
450    return "null";
451
452  }
453
454  }
455
456    /**
457     * A parameter passed to or received from the operation.
458     */
459    @Child(name = "parameter", type = {}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
460    @Description(shortDefinition="Operation Parameter", formalDefinition="A parameter passed to or received from the operation." )
461    protected List<ParametersParameterComponent> parameter;
462
463    private static final long serialVersionUID = -1495940293L;
464
465  /*
466   * Constructor
467   */
468    public Parameters() {
469      super();
470    }
471
472    /**
473     * @return {@link #parameter} (A parameter passed to or received from the operation.)
474     */
475    public List<ParametersParameterComponent> getParameter() { 
476      if (this.parameter == null)
477        this.parameter = new ArrayList<ParametersParameterComponent>();
478      return this.parameter;
479    }
480
481    public boolean hasParameter() { 
482      if (this.parameter == null)
483        return false;
484      for (ParametersParameterComponent item : this.parameter)
485        if (!item.isEmpty())
486          return true;
487      return false;
488    }
489
490    /**
491     * @return {@link #parameter} (A parameter passed to or received from the operation.)
492     */
493    // syntactic sugar
494    public ParametersParameterComponent addParameter() { //3
495      ParametersParameterComponent t = new ParametersParameterComponent();
496      if (this.parameter == null)
497        this.parameter = new ArrayList<ParametersParameterComponent>();
498      this.parameter.add(t);
499      return t;
500    }
501
502    // syntactic sugar
503    public Parameters addParameter(ParametersParameterComponent t) { //3
504      if (t == null)
505        return this;
506      if (this.parameter == null)
507        this.parameter = new ArrayList<ParametersParameterComponent>();
508      this.parameter.add(t);
509      return this;
510    }
511
512      protected void listChildren(List<Property> childrenList) {
513        super.listChildren(childrenList);
514        childrenList.add(new Property("parameter", "", "A parameter passed to or received from the operation.", 0, java.lang.Integer.MAX_VALUE, parameter));
515      }
516
517      @Override
518      public void setProperty(String name, Base value) throws FHIRException {
519        if (name.equals("parameter"))
520          this.getParameter().add((ParametersParameterComponent) value);
521        else
522          super.setProperty(name, value);
523      }
524
525      @Override
526      public Base addChild(String name) throws FHIRException {
527        if (name.equals("parameter")) {
528          return addParameter();
529        }
530        else
531          return super.addChild(name);
532      }
533
534  public String fhirType() {
535    return "Parameters";
536
537  }
538
539      public Parameters copy() {
540        Parameters dst = new Parameters();
541        copyValues(dst);
542        if (parameter != null) {
543          dst.parameter = new ArrayList<ParametersParameterComponent>();
544          for (ParametersParameterComponent i : parameter)
545            dst.parameter.add(i.copy());
546        };
547        return dst;
548      }
549
550      protected Parameters typedCopy() {
551        return copy();
552      }
553
554      @Override
555      public boolean equalsDeep(Base other) {
556        if (!super.equalsDeep(other))
557          return false;
558        if (!(other instanceof Parameters))
559          return false;
560        Parameters o = (Parameters) other;
561        return compareDeep(parameter, o.parameter, true);
562      }
563
564      @Override
565      public boolean equalsShallow(Base other) {
566        if (!super.equalsShallow(other))
567          return false;
568        if (!(other instanceof Parameters))
569          return false;
570        Parameters o = (Parameters) other;
571        return true;
572      }
573
574      public boolean isEmpty() {
575        return super.isEmpty() && (parameter == null || parameter.isEmpty());
576      }
577
578  @Override
579  public ResourceType getResourceType() {
580    return ResourceType.Parameters;
581   }
582
583
584}
585