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