001package org.hl7.fhir.dstu2016may.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
038import org.hl7.fhir.instance.model.api.IBaseParameters;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044/**
045 * 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.
046 */
047@ResourceDef(name="Parameters", profile="http://hl7.org/fhir/Profile/Parameters")
048public class Parameters extends Resource implements IBaseParameters {
049
050    @Block()
051    public static class ParametersParameterComponent extends BackboneElement implements IBaseBackboneElement {
052        /**
053         * The name of the parameter (reference to the operation definition).
054         */
055        @Child(name = "name", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false)
056        @Description(shortDefinition="Name from the definition", formalDefinition="The name of the parameter (reference to the operation definition)." )
057        protected StringType name;
058
059        /**
060         * If the parameter is a data type.
061         */
062        @Child(name = "value", type = {}, order=2, min=0, max=1, modifier=false, summary=false)
063        @Description(shortDefinition="If parameter is a data type", formalDefinition="If the parameter is a data type." )
064        protected org.hl7.fhir.dstu2016may.model.Type value;
065
066        /**
067         * If the parameter is a whole resource.
068         */
069        @Child(name = "resource", type = {Resource.class}, order=3, min=0, max=1, modifier=false, summary=false)
070        @Description(shortDefinition="If parameter is a whole resource", formalDefinition="If the parameter is a whole resource." )
071        protected Resource resource;
072
073        /**
074         * A named part of a parameter. In many implementation context, a set of named parts is known as a "Tuple".
075         */
076        @Child(name = "part", type = {ParametersParameterComponent.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
077        @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\"." )
078        protected List<ParametersParameterComponent> part;
079
080        private static final long serialVersionUID = -839605058L;
081
082    /**
083     * Constructor
084     */
085      public ParametersParameterComponent() {
086        super();
087      }
088
089    /**
090     * Constructor
091     */
092      public ParametersParameterComponent(StringType name) {
093        super();
094        this.name = name;
095      }
096
097        /**
098         * @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
099         */
100        public StringType getNameElement() { 
101          if (this.name == null)
102            if (Configuration.errorOnAutoCreate())
103              throw new Error("Attempt to auto-create ParametersParameterComponent.name");
104            else if (Configuration.doAutoCreate())
105              this.name = new StringType(); // bb
106          return this.name;
107        }
108
109        public boolean hasNameElement() { 
110          return this.name != null && !this.name.isEmpty();
111        }
112
113        public boolean hasName() { 
114          return this.name != null && !this.name.isEmpty();
115        }
116
117        /**
118         * @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
119         */
120        public ParametersParameterComponent setNameElement(StringType value) { 
121          this.name = value;
122          return this;
123        }
124
125        /**
126         * @return The name of the parameter (reference to the operation definition).
127         */
128        public String getName() { 
129          return this.name == null ? null : this.name.getValue();
130        }
131
132        /**
133         * @param value The name of the parameter (reference to the operation definition).
134         */
135        public ParametersParameterComponent setName(String value) { 
136            if (this.name == null)
137              this.name = new StringType();
138            this.name.setValue(value);
139          return this;
140        }
141
142        /**
143         * @return {@link #value} (If the parameter is a data type.)
144         */
145        public org.hl7.fhir.dstu2016may.model.Type getValue() { 
146          return this.value;
147        }
148
149        public boolean hasValue() { 
150          return this.value != null && !this.value.isEmpty();
151        }
152
153        /**
154         * @param value {@link #value} (If the parameter is a data type.)
155         */
156        public ParametersParameterComponent setValue(org.hl7.fhir.dstu2016may.model.Type value) { 
157          this.value = value;
158          return this;
159        }
160
161        /**
162         * @return {@link #resource} (If the parameter is a whole resource.)
163         */
164        public Resource getResource() { 
165          return this.resource;
166        }
167
168        public boolean hasResource() { 
169          return this.resource != null && !this.resource.isEmpty();
170        }
171
172        /**
173         * @param value {@link #resource} (If the parameter is a whole resource.)
174         */
175        public ParametersParameterComponent setResource(Resource value) { 
176          this.resource = value;
177          return this;
178        }
179
180        /**
181         * @return {@link #part} (A named part of a parameter. In many implementation context, a set of named parts is known as a "Tuple".)
182         */
183        public List<ParametersParameterComponent> getPart() { 
184          if (this.part == null)
185            this.part = new ArrayList<ParametersParameterComponent>();
186          return this.part;
187        }
188
189        public boolean hasPart() { 
190          if (this.part == null)
191            return false;
192          for (ParametersParameterComponent item : this.part)
193            if (!item.isEmpty())
194              return true;
195          return false;
196        }
197
198        /**
199         * @return {@link #part} (A named part of a parameter. In many implementation context, a set of named parts is known as a "Tuple".)
200         */
201    // syntactic sugar
202        public ParametersParameterComponent addPart() { //3
203          ParametersParameterComponent t = new ParametersParameterComponent();
204          if (this.part == null)
205            this.part = new ArrayList<ParametersParameterComponent>();
206          this.part.add(t);
207          return t;
208        }
209
210    // syntactic sugar
211        public ParametersParameterComponent addPart(ParametersParameterComponent t) { //3
212          if (t == null)
213            return this;
214          if (this.part == null)
215            this.part = new ArrayList<ParametersParameterComponent>();
216          this.part.add(t);
217          return this;
218        }
219
220        protected void listChildren(List<Property> childrenList) {
221          super.listChildren(childrenList);
222          childrenList.add(new Property("name", "string", "The name of the parameter (reference to the operation definition).", 0, java.lang.Integer.MAX_VALUE, name));
223          childrenList.add(new Property("value[x]", "*", "If the parameter is a data type.", 0, java.lang.Integer.MAX_VALUE, value));
224          childrenList.add(new Property("resource", "Resource", "If the parameter is a whole resource.", 0, java.lang.Integer.MAX_VALUE, resource));
225          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));
226        }
227
228      @Override
229      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
230        switch (hash) {
231        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
232        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // org.hl7.fhir.dstu2016may.model.Type
233        case -341064690: /*resource*/ return this.resource == null ? new Base[0] : new Base[] {this.resource}; // Resource
234        case 3433459: /*part*/ return this.part == null ? new Base[0] : this.part.toArray(new Base[this.part.size()]); // ParametersParameterComponent
235        default: return super.getProperty(hash, name, checkValid);
236        }
237
238      }
239
240      @Override
241      public void setProperty(int hash, String name, Base value) throws FHIRException {
242        switch (hash) {
243        case 3373707: // name
244          this.name = castToString(value); // StringType
245          break;
246        case 111972721: // value
247          this.value = (org.hl7.fhir.dstu2016may.model.Type) value; // org.hl7.fhir.dstu2016may.model.Type
248          break;
249        case -341064690: // resource
250          this.resource = castToResource(value); // Resource
251          break;
252        case 3433459: // part
253          this.getPart().add((ParametersParameterComponent) value); // ParametersParameterComponent
254          break;
255        default: super.setProperty(hash, name, value);
256        }
257
258      }
259
260      @Override
261      public void setProperty(String name, Base value) throws FHIRException {
262        if (name.equals("name"))
263          this.name = castToString(value); // StringType
264        else if (name.equals("value[x]"))
265          this.value = (org.hl7.fhir.dstu2016may.model.Type) value; // org.hl7.fhir.dstu2016may.model.Type
266        else if (name.equals("resource"))
267          this.resource = castToResource(value); // Resource
268        else if (name.equals("part"))
269          this.getPart().add((ParametersParameterComponent) value);
270        else
271          super.setProperty(name, value);
272      }
273
274      @Override
275      public Base makeProperty(int hash, String name) throws FHIRException {
276        switch (hash) {
277        case 3373707: throw new FHIRException("Cannot make property name as it is not a complex type"); // StringType
278        case -1410166417:  return getValue(); // org.hl7.fhir.dstu2016may.model.Type
279        case -341064690: throw new FHIRException("Cannot make property resource as it is not a complex type"); // Resource
280        case 3433459:  return addPart(); // ParametersParameterComponent
281        default: return super.makeProperty(hash, name);
282        }
283
284      }
285
286      @Override
287      public Base addChild(String name) throws FHIRException {
288        if (name.equals("name")) {
289          throw new FHIRException("Cannot call addChild on a primitive type Parameters.name");
290        }
291        else if (name.equals("valueBoolean")) {
292          this.value = new BooleanType();
293          return this.value;
294        }
295        else if (name.equals("valueInteger")) {
296          this.value = new IntegerType();
297          return this.value;
298        }
299        else if (name.equals("valueDecimal")) {
300          this.value = new DecimalType();
301          return this.value;
302        }
303        else if (name.equals("valueBase64Binary")) {
304          this.value = new Base64BinaryType();
305          return this.value;
306        }
307        else if (name.equals("valueInstant")) {
308          this.value = new InstantType();
309          return this.value;
310        }
311        else if (name.equals("valueString")) {
312          this.value = new StringType();
313          return this.value;
314        }
315        else if (name.equals("valueUri")) {
316          this.value = new UriType();
317          return this.value;
318        }
319        else if (name.equals("valueDate")) {
320          this.value = new DateType();
321          return this.value;
322        }
323        else if (name.equals("valueDateTime")) {
324          this.value = new DateTimeType();
325          return this.value;
326        }
327        else if (name.equals("valueTime")) {
328          this.value = new TimeType();
329          return this.value;
330        }
331        else if (name.equals("valueCode")) {
332          this.value = new CodeType();
333          return this.value;
334        }
335        else if (name.equals("valueOid")) {
336          this.value = new OidType();
337          return this.value;
338        }
339        else if (name.equals("valueId")) {
340          this.value = new IdType();
341          return this.value;
342        }
343        else if (name.equals("valueUnsignedInt")) {
344          this.value = new UnsignedIntType();
345          return this.value;
346        }
347        else if (name.equals("valuePositiveInt")) {
348          this.value = new PositiveIntType();
349          return this.value;
350        }
351        else if (name.equals("valueMarkdown")) {
352          this.value = new MarkdownType();
353          return this.value;
354        }
355        else if (name.equals("valueAnnotation")) {
356          this.value = new Annotation();
357          return this.value;
358        }
359        else if (name.equals("valueAttachment")) {
360          this.value = new Attachment();
361          return this.value;
362        }
363        else if (name.equals("valueIdentifier")) {
364          this.value = new Identifier();
365          return this.value;
366        }
367        else if (name.equals("valueCodeableConcept")) {
368          this.value = new CodeableConcept();
369          return this.value;
370        }
371        else if (name.equals("valueCoding")) {
372          this.value = new Coding();
373          return this.value;
374        }
375        else if (name.equals("valueQuantity")) {
376          this.value = new Quantity();
377          return this.value;
378        }
379        else if (name.equals("valueRange")) {
380          this.value = new Range();
381          return this.value;
382        }
383        else if (name.equals("valuePeriod")) {
384          this.value = new Period();
385          return this.value;
386        }
387        else if (name.equals("valueRatio")) {
388          this.value = new Ratio();
389          return this.value;
390        }
391        else if (name.equals("valueSampledData")) {
392          this.value = new SampledData();
393          return this.value;
394        }
395        else if (name.equals("valueSignature")) {
396          this.value = new Signature();
397          return this.value;
398        }
399        else if (name.equals("valueHumanName")) {
400          this.value = new HumanName();
401          return this.value;
402        }
403        else if (name.equals("valueAddress")) {
404          this.value = new Address();
405          return this.value;
406        }
407        else if (name.equals("valueContactPoint")) {
408          this.value = new ContactPoint();
409          return this.value;
410        }
411        else if (name.equals("valueTiming")) {
412          this.value = new Timing();
413          return this.value;
414        }
415        else if (name.equals("valueReference")) {
416          this.value = new Reference();
417          return this.value;
418        }
419        else if (name.equals("valueMeta")) {
420          this.value = new Meta();
421          return this.value;
422        }
423        else if (name.equals("resource")) {
424          throw new FHIRException("Cannot call addChild on an abstract type Parameters.resource");
425        }
426        else if (name.equals("part")) {
427          return addPart();
428        }
429        else
430          return super.addChild(name);
431      }
432
433      public ParametersParameterComponent copy() {
434        ParametersParameterComponent dst = new ParametersParameterComponent();
435        copyValues(dst);
436        dst.name = name == null ? null : name.copy();
437        dst.value = value == null ? null : value.copy();
438        dst.resource = resource == null ? null : resource.copy();
439        if (part != null) {
440          dst.part = new ArrayList<ParametersParameterComponent>();
441          for (ParametersParameterComponent i : part)
442            dst.part.add(i.copy());
443        };
444        return dst;
445      }
446
447      @Override
448      public boolean equalsDeep(Base other) {
449        if (!super.equalsDeep(other))
450          return false;
451        if (!(other instanceof ParametersParameterComponent))
452          return false;
453        ParametersParameterComponent o = (ParametersParameterComponent) other;
454        return compareDeep(name, o.name, true) && compareDeep(value, o.value, true) && compareDeep(resource, o.resource, true)
455           && compareDeep(part, o.part, true);
456      }
457
458      @Override
459      public boolean equalsShallow(Base other) {
460        if (!super.equalsShallow(other))
461          return false;
462        if (!(other instanceof ParametersParameterComponent))
463          return false;
464        ParametersParameterComponent o = (ParametersParameterComponent) other;
465        return compareValues(name, o.name, true);
466      }
467
468      public boolean isEmpty() {
469        return super.isEmpty() && (name == null || name.isEmpty()) && (value == null || value.isEmpty())
470           && (resource == null || resource.isEmpty()) && (part == null || part.isEmpty());
471      }
472
473  public String fhirType() {
474    return "null";
475
476  }
477
478  }
479
480    /**
481     * A parameter passed to or received from the operation.
482     */
483    @Child(name = "parameter", type = {}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
484    @Description(shortDefinition="Operation Parameter", formalDefinition="A parameter passed to or received from the operation." )
485    protected List<ParametersParameterComponent> parameter;
486
487    private static final long serialVersionUID = -1495940293L;
488
489  /**
490   * Constructor
491   */
492    public Parameters() {
493      super();
494    }
495
496    /**
497     * @return {@link #parameter} (A parameter passed to or received from the operation.)
498     */
499    public List<ParametersParameterComponent> getParameter() { 
500      if (this.parameter == null)
501        this.parameter = new ArrayList<ParametersParameterComponent>();
502      return this.parameter;
503    }
504
505    public boolean hasParameter() { 
506      if (this.parameter == null)
507        return false;
508      for (ParametersParameterComponent item : this.parameter)
509        if (!item.isEmpty())
510          return true;
511      return false;
512    }
513
514    /**
515     * @return {@link #parameter} (A parameter passed to or received from the operation.)
516     */
517    // syntactic sugar
518    public ParametersParameterComponent addParameter() { //3
519      ParametersParameterComponent t = new ParametersParameterComponent();
520      if (this.parameter == null)
521        this.parameter = new ArrayList<ParametersParameterComponent>();
522      this.parameter.add(t);
523      return t;
524    }
525
526    // syntactic sugar
527    public Parameters addParameter(ParametersParameterComponent t) { //3
528      if (t == null)
529        return this;
530      if (this.parameter == null)
531        this.parameter = new ArrayList<ParametersParameterComponent>();
532      this.parameter.add(t);
533      return this;
534    }
535
536      protected void listChildren(List<Property> childrenList) {
537        super.listChildren(childrenList);
538        childrenList.add(new Property("parameter", "", "A parameter passed to or received from the operation.", 0, java.lang.Integer.MAX_VALUE, parameter));
539      }
540
541      @Override
542      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
543        switch (hash) {
544        case 1954460585: /*parameter*/ return this.parameter == null ? new Base[0] : this.parameter.toArray(new Base[this.parameter.size()]); // ParametersParameterComponent
545        default: return super.getProperty(hash, name, checkValid);
546        }
547
548      }
549
550      @Override
551      public void setProperty(int hash, String name, Base value) throws FHIRException {
552        switch (hash) {
553        case 1954460585: // parameter
554          this.getParameter().add((ParametersParameterComponent) value); // ParametersParameterComponent
555          break;
556        default: super.setProperty(hash, name, value);
557        }
558
559      }
560
561      @Override
562      public void setProperty(String name, Base value) throws FHIRException {
563        if (name.equals("parameter"))
564          this.getParameter().add((ParametersParameterComponent) value);
565        else
566          super.setProperty(name, value);
567      }
568
569      @Override
570      public Base makeProperty(int hash, String name) throws FHIRException {
571        switch (hash) {
572        case 1954460585:  return addParameter(); // ParametersParameterComponent
573        default: return super.makeProperty(hash, name);
574        }
575
576      }
577
578      @Override
579      public Base addChild(String name) throws FHIRException {
580        if (name.equals("parameter")) {
581          return addParameter();
582        }
583        else
584          return super.addChild(name);
585      }
586
587  public String fhirType() {
588    return "Parameters";
589
590  }
591
592      public Parameters copy() {
593        Parameters dst = new Parameters();
594        copyValues(dst);
595        if (parameter != null) {
596          dst.parameter = new ArrayList<ParametersParameterComponent>();
597          for (ParametersParameterComponent i : parameter)
598            dst.parameter.add(i.copy());
599        };
600        return dst;
601      }
602
603      protected Parameters typedCopy() {
604        return copy();
605      }
606
607      @Override
608      public boolean equalsDeep(Base other) {
609        if (!super.equalsDeep(other))
610          return false;
611        if (!(other instanceof Parameters))
612          return false;
613        Parameters o = (Parameters) other;
614        return compareDeep(parameter, o.parameter, true);
615      }
616
617      @Override
618      public boolean equalsShallow(Base other) {
619        if (!super.equalsShallow(other))
620          return false;
621        if (!(other instanceof Parameters))
622          return false;
623        Parameters o = (Parameters) other;
624        return true;
625      }
626
627      public boolean isEmpty() {
628        return super.isEmpty() && (parameter == null || parameter.isEmpty());
629      }
630
631  @Override
632  public ResourceType getResourceType() {
633    return ResourceType.Parameters;
634   }
635
636
637}
638