1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   // Generated from: ../../../../../../metaschema/unit-tests.yaml
6   // Do not edit - changes will be lost when regenerated.
7   
8   package dev.metaschema.model.testing.testsuite;
9   
10  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
11  import org.apache.commons.lang3.builder.ToStringStyle;
12  
13  import java.util.LinkedList;
14  import java.util.List;
15  
16  import dev.metaschema.core.datatype.adapter.TokenAdapter;
17  import dev.metaschema.core.model.IBoundObject;
18  import dev.metaschema.core.model.IMetaschemaData;
19  import dev.metaschema.core.model.JsonGroupAsBehavior;
20  import dev.metaschema.core.model.constraint.IConstraint;
21  import dev.metaschema.core.util.ObjectUtils;
22  import dev.metaschema.databind.model.annotations.AllowedValue;
23  import dev.metaschema.databind.model.annotations.AllowedValues;
24  import dev.metaschema.databind.model.annotations.BoundAssembly;
25  import dev.metaschema.databind.model.annotations.BoundFlag;
26  import dev.metaschema.databind.model.annotations.GroupAs;
27  import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
28  import dev.metaschema.databind.model.annotations.ValueConstraints;
29  import edu.umd.cs.findbugs.annotations.NonNull;
30  import edu.umd.cs.findbugs.annotations.Nullable;
31  
32  /**
33   * Defines schema generation parameters and expected results.
34   */
35  @MetaschemaAssembly(
36      formalName = "Generate Schema",
37      description = "Defines schema generation parameters and expected results.",
38      name = "generate-schema",
39      moduleClass = MetaschemaTestSuiteModule.class)
40  public class GenerateSchema implements IBoundObject {
41    private final IMetaschemaData __metaschemaData;
42  
43    /**
44     * The expected result of schema generation.
45     */
46    @BoundFlag(
47        formalName = "Generation Result",
48        description = "The expected result of schema generation.",
49        name = "generation-result",
50        defaultValue = "SUCCESS",
51        typeAdapter = TokenAdapter.class,
52        valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {
53            @AllowedValue(value = "SUCCESS", description = "Generation succeeded."),
54            @AllowedValue(value = "FAILURE", description = "Generation resulted in failure caused by some error.") })))
55    private String _generationResult;
56  
57    /**
58     * The expected result of content validation.
59     */
60    @BoundFlag(
61        formalName = "Validation Result",
62        description = "The expected result of content validation.",
63        name = "validation-result",
64        defaultValue = "VALID",
65        typeAdapter = TokenAdapter.class,
66        valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR,
67            values = { @AllowedValue(value = "VALID", description = "Validation succeeded."),
68                @AllowedValue(value = "INVALID",
69                    description = "Validation resulted in failure caused by some content defect or error.") })))
70    private String _validationResult;
71  
72    /**
73     * Reference to a metaschema module to load.
74     */
75    @BoundAssembly(
76        formalName = "Metaschema",
77        description = "Reference to a metaschema module to load.",
78        useName = "metaschema",
79        minOccurs = 1)
80    private Metaschema _metaschema;
81  
82    /**
83     * A schema generation comparison test case.
84     */
85    @BoundAssembly(
86        formalName = "Generation Case",
87        description = "A schema generation comparison test case.",
88        useName = "generation-case",
89        maxOccurs = -1,
90        groupAs = @GroupAs(name = "generation-cases", inJson = JsonGroupAsBehavior.LIST))
91    private List<GenerationCase> _generationCases;
92  
93    /**
94     * Constructs a new
95     * {@code dev.metaschema.model.testing.testsuite.GenerateSchema} instance with
96     * no metadata.
97     */
98    public GenerateSchema() {
99      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 }