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#WorkflowStepInput</I><br>
012 *
013 * <BLOCKQUOTE>
014 *
015 * TODO:
016 *
017 * </BLOCKQUOTE>
018 */
019public class WorkflowStepInputImpl extends SavableImpl implements WorkflowStepInput {
020  private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build();
021  private java.util.Map<String, Object> extensionFields_ = new java.util.HashMap<String, Object>();
022
023  private java.util.Optional<String> id;
024
025  /**
026   * Getter for property <I>https://w3id.org/cwl/cwl#Identified/id</I><br>
027   *
028   * <BLOCKQUOTE>
029   *
030   * The unique identifier for this object. *
031   *
032   * </BLOCKQUOTE>
033   */
034  public java.util.Optional<String> getId() {
035    return this.id;
036  }
037
038  private Object source;
039
040  /**
041   * Getter for property <I>https://w3id.org/cwl/cwl#source</I><br>
042   *
043   * <BLOCKQUOTE>
044   *
045   * Specifies one or more workflow parameters that will provide input to the underlying step
046   * parameter. *
047   *
048   * </BLOCKQUOTE>
049   */
050  public Object getSource() {
051    return this.source;
052  }
053
054  private java.util.Optional<String> label;
055
056  /**
057   * Getter for property <I>https://w3id.org/cwl/cwl#Labeled/label</I><br>
058   *
059   * <BLOCKQUOTE>
060   *
061   * A short, human-readable label of this object. *
062   *
063   * </BLOCKQUOTE>
064   */
065  public java.util.Optional<String> getLabel() {
066    return this.label;
067  }
068
069  private java.util.Optional<Object> default_;
070
071  /**
072   * Getter for property <I>https://w3id.org/cwl/salad#default</I><br>
073   *
074   * <BLOCKQUOTE>
075   *
076   * The default value for this parameter to use if either there is no `source` field, or the value
077   * produced by the `source` is `null`. The default must be applied prior to scattering or
078   * evaluating `valueFrom`. *
079   *
080   * </BLOCKQUOTE>
081   */
082  public java.util.Optional<Object> getDefault() {
083    return this.default_;
084  }
085
086  /**
087   * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of
088   * WorkflowStepInputImpl.
089   *
090   * @param __doc_ Document fragment to load this record object from (presumably a {@link
091   *     java.util.Map}).
092   * @param __baseUri_ Base URI to generate child document IDs against.
093   * @param __loadingOptions Context for loading URIs and populating objects.
094   * @param __docRoot_ ID at this position in the document (if available) (maybe?)
095   * @throws ValidationException If the document fragment is not a {@link java.util.Map} or
096   *     validation of fields fails.
097   */
098  public WorkflowStepInputImpl(
099      final Object __doc_,
100      final String __baseUri_,
101      LoadingOptions __loadingOptions,
102      final String __docRoot_) {
103    super(__doc_, __baseUri_, __loadingOptions, __docRoot_);
104    // Prefix plumbing variables with '__' to reduce likelihood of collision with
105    // generated names.
106    String __baseUri = __baseUri_;
107    String __docRoot = __docRoot_;
108    if (!(__doc_ instanceof java.util.Map)) {
109      throw new ValidationException("WorkflowStepInputImpl called on non-map");
110    }
111    final java.util.Map<String, Object> __doc = (java.util.Map<String, Object>) __doc_;
112    final java.util.List<ValidationException> __errors =
113        new java.util.ArrayList<ValidationException>();
114    if (__loadingOptions != null) {
115      this.loadingOptions_ = __loadingOptions;
116    }
117    java.util.Optional<String> id;
118
119    if (__doc.containsKey("id")) {
120      try {
121        id =
122            LoaderInstances.uri_optional_StringInstance_True_False_None.loadField(
123                __doc.get("id"), __baseUri, __loadingOptions);
124      } catch (ValidationException e) {
125        id = null; // won't be used but prevents compiler from complaining.
126        final String __message = "the `id` field is not valid because:";
127        __errors.add(new ValidationException(__message, e));
128      }
129
130    } else {
131      id = null;
132    }
133
134    if (id == null) {
135      if (__docRoot != null) {
136        id = java.util.Optional.of(__docRoot);
137      } else {
138        id = java.util.Optional.of("_:" + java.util.UUID.randomUUID().toString());
139      }
140    }
141    __baseUri = (String) id.orElse(null);
142    Object source;
143
144    if (__doc.containsKey("source")) {
145      try {
146        source =
147            LoaderInstances
148                .uri_union_of_NullInstance_or_StringInstance_or_array_of_StringInstance_False_False_2
149                .loadField(__doc.get("source"), __baseUri, __loadingOptions);
150      } catch (ValidationException e) {
151        source = null; // won't be used but prevents compiler from complaining.
152        final String __message = "the `source` field is not valid because:";
153        __errors.add(new ValidationException(__message, e));
154      }
155
156    } else {
157      source = null;
158    }
159    java.util.Optional<String> label;
160
161    if (__doc.containsKey("label")) {
162      try {
163        label =
164            LoaderInstances.optional_StringInstance.loadField(
165                __doc.get("label"), __baseUri, __loadingOptions);
166      } catch (ValidationException e) {
167        label = null; // won't be used but prevents compiler from complaining.
168        final String __message = "the `label` field is not valid because:";
169        __errors.add(new ValidationException(__message, e));
170      }
171
172    } else {
173      label = null;
174    }
175    java.util.Optional<Object> default_;
176
177    if (__doc.containsKey("default")) {
178      try {
179        default_ =
180            LoaderInstances.optional_AnyInstance.loadField(
181                __doc.get("default"), __baseUri, __loadingOptions);
182      } catch (ValidationException e) {
183        default_ = null; // won't be used but prevents compiler from complaining.
184        final String __message = "the `default` field is not valid because:";
185        __errors.add(new ValidationException(__message, e));
186      }
187
188    } else {
189      default_ = null;
190    }
191    if (!__errors.isEmpty()) {
192      throw new ValidationException("Trying 'RecordField'", __errors);
193    }
194    this.id = (java.util.Optional<String>) id;
195    this.source = (Object) source;
196    this.label = (java.util.Optional<String>) label;
197    this.default_ = (java.util.Optional<Object>) default_;
198  }
199}