001package org.galaxyproject.gxformat2.v19_09;
002
003import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances;
004import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions;
005import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder;
006import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl;
007import org.galaxyproject.gxformat2.v19_09.utils.ValidationException;
008
009/**
010 * Auto-generated class implementation for
011 * <I>https://galaxyproject.org/gxformat2/v19_09#WorkflowInputParameter</I><br>
012 */
013public class WorkflowInputParameterImpl extends SavableImpl implements WorkflowInputParameter {
014  private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build();
015  private java.util.Map<String, Object> extensionFields_ = new java.util.HashMap<String, Object>();
016
017  private java.util.Optional<String> id;
018
019  /**
020   * Getter for property <I>https://w3id.org/cwl/cwl#Identified/id</I><br>
021   *
022   * <BLOCKQUOTE>
023   *
024   * The unique identifier for this object. *
025   *
026   * </BLOCKQUOTE>
027   */
028  public java.util.Optional<String> getId() {
029    return this.id;
030  }
031
032  private Object doc;
033
034  /**
035   * Getter for property <I>https://w3id.org/cwl/salad#Documented/doc</I><br>
036   *
037   * <BLOCKQUOTE>
038   *
039   * A documentation string for this object, or an array of strings which should be concatenated. *
040   *
041   * </BLOCKQUOTE>
042   */
043  public Object getDoc() {
044    return this.doc;
045  }
046
047  private java.util.Optional<Object> default_;
048
049  /**
050   * Getter for property <I>https://w3id.org/cwl/salad#default</I><br>
051   *
052   * <BLOCKQUOTE>
053   *
054   * The default value to use for this parameter if the parameter is missing from the input object,
055   * or if the value of the parameter in the input object is `null`. Default values are applied
056   * before evaluating expressions (e.g. dependent `valueFrom` fields). *
057   *
058   * </BLOCKQUOTE>
059   */
060  public java.util.Optional<Object> getDefault() {
061    return this.default_;
062  }
063
064  private java.util.Optional<StepPosition> position;
065
066  /**
067   * Getter for property
068   * <I>https://galaxyproject.org/gxformat2/gxformat2common#HasStepPosition/position</I><br>
069   */
070  public java.util.Optional<StepPosition> getPosition() {
071    return this.position;
072  }
073
074  private Object type;
075
076  /**
077   * Getter for property <I>https://w3id.org/cwl/salad#type</I><br>
078   *
079   * <BLOCKQUOTE>
080   *
081   * Specify valid types of data that may be assigned to this parameter. *
082   *
083   * </BLOCKQUOTE>
084   */
085  public Object getType() {
086    return this.type;
087  }
088
089  /**
090   * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of
091   * WorkflowInputParameterImpl.
092   *
093   * @param __doc_ Document fragment to load this record object from (presumably a {@link
094   *     java.util.Map}).
095   * @param __baseUri_ Base URI to generate child document IDs against.
096   * @param __loadingOptions Context for loading URIs and populating objects.
097   * @param __docRoot_ ID at this position in the document (if available) (maybe?)
098   * @throws ValidationException If the document fragment is not a {@link java.util.Map} or
099   *     validation of fields fails.
100   */
101  public WorkflowInputParameterImpl(
102      final Object __doc_,
103      final String __baseUri_,
104      LoadingOptions __loadingOptions,
105      final String __docRoot_) {
106    super(__doc_, __baseUri_, __loadingOptions, __docRoot_);
107    // Prefix plumbing variables with '__' to reduce likelihood of collision with
108    // generated names.
109    String __baseUri = __baseUri_;
110    String __docRoot = __docRoot_;
111    if (!(__doc_ instanceof java.util.Map)) {
112      throw new ValidationException("WorkflowInputParameterImpl called on non-map");
113    }
114    final java.util.Map<String, Object> __doc = (java.util.Map<String, Object>) __doc_;
115    final java.util.List<ValidationException> __errors =
116        new java.util.ArrayList<ValidationException>();
117    if (__loadingOptions != null) {
118      this.loadingOptions_ = __loadingOptions;
119    }
120    java.util.Optional<String> id;
121
122    if (__doc.containsKey("id")) {
123      try {
124        id =
125            LoaderInstances.uri_optional_StringInstance_True_False_None.loadField(
126                __doc.get("id"), __baseUri, __loadingOptions);
127      } catch (ValidationException e) {
128        id = null; // won't be used but prevents compiler from complaining.
129        final String __message = "the `id` field is not valid because:";
130        __errors.add(new ValidationException(__message, e));
131      }
132
133    } else {
134      id = null;
135    }
136
137    if (id == null) {
138      if (__docRoot != null) {
139        id = java.util.Optional.of(__docRoot);
140      } else {
141        id = java.util.Optional.of("_:" + java.util.UUID.randomUUID().toString());
142      }
143    }
144    __baseUri = (String) id.orElse(null);
145    Object doc;
146
147    if (__doc.containsKey("doc")) {
148      try {
149        doc =
150            LoaderInstances.union_of_NullInstance_or_StringInstance_or_array_of_StringInstance
151                .loadField(__doc.get("doc"), __baseUri, __loadingOptions);
152      } catch (ValidationException e) {
153        doc = null; // won't be used but prevents compiler from complaining.
154        final String __message = "the `doc` field is not valid because:";
155        __errors.add(new ValidationException(__message, e));
156      }
157
158    } else {
159      doc = null;
160    }
161    java.util.Optional<Object> default_;
162
163    if (__doc.containsKey("default")) {
164      try {
165        default_ =
166            LoaderInstances.optional_AnyInstance.loadField(
167                __doc.get("default"), __baseUri, __loadingOptions);
168      } catch (ValidationException e) {
169        default_ = null; // won't be used but prevents compiler from complaining.
170        final String __message = "the `default` field is not valid because:";
171        __errors.add(new ValidationException(__message, e));
172      }
173
174    } else {
175      default_ = null;
176    }
177    java.util.Optional<StepPosition> position;
178
179    if (__doc.containsKey("position")) {
180      try {
181        position =
182            LoaderInstances.optional_StepPosition.loadField(
183                __doc.get("position"), __baseUri, __loadingOptions);
184      } catch (ValidationException e) {
185        position = null; // won't be used but prevents compiler from complaining.
186        final String __message = "the `position` field is not valid because:";
187        __errors.add(new ValidationException(__message, e));
188      }
189
190    } else {
191      position = null;
192    }
193    Object type;
194
195    if (__doc.containsKey("type")) {
196      try {
197        type =
198            LoaderInstances.typedsl_union_of_GalaxyType_or_StringInstance_or_NullInstance_2
199                .loadField(__doc.get("type"), __baseUri, __loadingOptions);
200      } catch (ValidationException e) {
201        type = null; // won't be used but prevents compiler from complaining.
202        final String __message = "the `type` field is not valid because:";
203        __errors.add(new ValidationException(__message, e));
204      }
205
206    } else {
207      type = null;
208    }
209    if (!__errors.isEmpty()) {
210      throw new ValidationException("Trying 'RecordField'", __errors);
211    }
212    this.doc = (Object) doc;
213    this.id = (java.util.Optional<String>) id;
214    this.default_ = (java.util.Optional<Object>) default_;
215    this.position = (java.util.Optional<StepPosition>) position;
216    this.type = (Object) type;
217  }
218}