001/*
002 * SPDX-FileCopyrightText: none
003 * SPDX-License-Identifier: CC0-1.0
004 */
005// Generated from: ../../../../../../metaschema/unit-tests.yaml
006// Do not edit - changes will be lost when regenerated.
007
008package dev.metaschema.model.testing.testsuite;
009
010import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
011import org.apache.commons.lang3.builder.ToStringStyle;
012
013import java.util.LinkedList;
014import java.util.List;
015
016import dev.metaschema.core.datatype.adapter.TokenAdapter;
017import dev.metaschema.core.model.IBoundObject;
018import dev.metaschema.core.model.IMetaschemaData;
019import dev.metaschema.core.model.JsonGroupAsBehavior;
020import dev.metaschema.core.model.constraint.IConstraint;
021import dev.metaschema.core.util.ObjectUtils;
022import dev.metaschema.databind.model.annotations.AllowedValue;
023import dev.metaschema.databind.model.annotations.AllowedValues;
024import dev.metaschema.databind.model.annotations.BoundAssembly;
025import dev.metaschema.databind.model.annotations.BoundFlag;
026import dev.metaschema.databind.model.annotations.GroupAs;
027import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
028import dev.metaschema.databind.model.annotations.ValueConstraints;
029import edu.umd.cs.findbugs.annotations.NonNull;
030import edu.umd.cs.findbugs.annotations.Nullable;
031
032/**
033 * Defines schema generation parameters and expected results.
034 */
035@MetaschemaAssembly(
036    formalName = "Generate Schema",
037    description = "Defines schema generation parameters and expected results.",
038    name = "generate-schema",
039    moduleClass = MetaschemaTestSuiteModule.class)
040public class GenerateSchema implements IBoundObject {
041  private final IMetaschemaData __metaschemaData;
042
043  /**
044   * The expected result of schema generation.
045   */
046  @BoundFlag(
047      formalName = "Generation Result",
048      description = "The expected result of schema generation.",
049      name = "generation-result",
050      defaultValue = "SUCCESS",
051      typeAdapter = TokenAdapter.class,
052      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {
053          @AllowedValue(value = "SUCCESS", description = "Generation succeeded."),
054          @AllowedValue(value = "FAILURE", description = "Generation resulted in failure caused by some error.") })))
055  private String _generationResult;
056
057  /**
058   * The expected result of content validation.
059   */
060  @BoundFlag(
061      formalName = "Validation Result",
062      description = "The expected result of content validation.",
063      name = "validation-result",
064      defaultValue = "VALID",
065      typeAdapter = TokenAdapter.class,
066      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR,
067          values = { @AllowedValue(value = "VALID", description = "Validation succeeded."),
068              @AllowedValue(value = "INVALID",
069                  description = "Validation resulted in failure caused by some content defect or error.") })))
070  private String _validationResult;
071
072  /**
073   * Reference to a metaschema module to load.
074   */
075  @BoundAssembly(
076      formalName = "Metaschema",
077      description = "Reference to a metaschema module to load.",
078      useName = "metaschema",
079      minOccurs = 1)
080  private Metaschema _metaschema;
081
082  /**
083   * A schema generation comparison test case.
084   */
085  @BoundAssembly(
086      formalName = "Generation Case",
087      description = "A schema generation comparison test case.",
088      useName = "generation-case",
089      maxOccurs = -1,
090      groupAs = @GroupAs(name = "generation-cases", inJson = JsonGroupAsBehavior.LIST))
091  private List<GenerationCase> _generationCases;
092
093  /**
094   * Constructs a new
095   * {@code dev.metaschema.model.testing.testsuite.GenerateSchema} instance with
096   * no metadata.
097   */
098  public GenerateSchema() {
099    this(null);
100  }
101
102  /**
103   * Constructs a new
104   * {@code dev.metaschema.model.testing.testsuite.GenerateSchema} instance with
105   * the specified metadata.
106   *
107   * @param data
108   *          the metaschema data, or {@code null} if none
109   */
110  public GenerateSchema(IMetaschemaData data) {
111    this.__metaschemaData = data;
112  }
113
114  @Override
115  public IMetaschemaData getMetaschemaData() {
116    return __metaschemaData;
117  }
118
119  /**
120   * Get the generation Result.
121   *
122   * <p>
123   * The expected result of schema generation.
124   *
125   * @return the generation-result value, or {@code null} if not set
126   */
127  @Nullable
128  public String getGenerationResult() {
129    return _generationResult;
130  }
131
132  /**
133   * Set the generation Result.
134   *
135   * <p>
136   * The expected result of schema generation.
137   *
138   * @param value
139   *          the generation-result value to set, or {@code null} to clear
140   */
141  public void setGenerationResult(@Nullable String value) {
142    _generationResult = value;
143  }
144
145  /**
146   * Get the validation Result.
147   *
148   * <p>
149   * The expected result of content validation.
150   *
151   * @return the validation-result value, or {@code null} if not set
152   */
153  @Nullable
154  public String getValidationResult() {
155    return _validationResult;
156  }
157
158  /**
159   * Set the validation Result.
160   *
161   * <p>
162   * The expected result of content validation.
163   *
164   * @param value
165   *          the validation-result value to set, or {@code null} to clear
166   */
167  public void setValidationResult(@Nullable String value) {
168    _validationResult = value;
169  }
170
171  /**
172   * Get the metaschema.
173   *
174   * <p>
175   * Reference to a metaschema module to load.
176   *
177   * @return the metaschema value
178   */
179  @NonNull
180  public Metaschema getMetaschema() {
181    return _metaschema;
182  }
183
184  /**
185   * Set the metaschema.
186   *
187   * <p>
188   * Reference to a metaschema module to load.
189   *
190   * @param value
191   *          the metaschema value to set
192   */
193  public void setMetaschema(@NonNull Metaschema value) {
194    _metaschema = value;
195  }
196
197  /**
198   * Get the generation Case.
199   *
200   * <p>
201   * A schema generation comparison test case.
202   *
203   * @return the generation-case value
204   */
205  @NonNull
206  public List<GenerationCase> getGenerationCases() {
207    if (_generationCases == null) {
208      _generationCases = new LinkedList<>();
209    }
210    return ObjectUtils.notNull(_generationCases);
211  }
212
213  /**
214   * Set the generation Case.
215   *
216   * <p>
217   * A schema generation comparison test case.
218   *
219   * @param value
220   *          the generation-case value to set
221   */
222  public void setGenerationCases(@NonNull List<GenerationCase> value) {
223    _generationCases = value;
224  }
225
226  /**
227   * Add a new {@link GenerationCase} item to the underlying collection.
228   *
229   * @param item
230   *          the item to add
231   * @return {@code true}
232   */
233  public boolean addGenerationCase(GenerationCase item) {
234    GenerationCase value = ObjectUtils.requireNonNull(item, "item cannot be null");
235    if (_generationCases == null) {
236      _generationCases = new LinkedList<>();
237    }
238    return _generationCases.add(value);
239  }
240
241  /**
242   * Remove the first matching {@link GenerationCase} item from the underlying
243   * collection.
244   *
245   * @param item
246   *          the item to remove
247   * @return {@code true} if the item was removed or {@code false} otherwise
248   */
249  public boolean removeGenerationCase(GenerationCase item) {
250    GenerationCase value = ObjectUtils.requireNonNull(item, "item cannot be null");
251    return _generationCases != null && _generationCases.remove(value);
252  }
253
254  @Override
255  public String toString() {
256    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
257  }
258}