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