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.net.URI;
14  import java.util.LinkedList;
15  import java.util.List;
16  
17  import dev.metaschema.core.datatype.adapter.StringAdapter;
18  import dev.metaschema.core.datatype.adapter.UriReferenceAdapter;
19  import dev.metaschema.core.model.IBoundObject;
20  import dev.metaschema.core.model.IMetaschemaData;
21  import dev.metaschema.core.model.JsonGroupAsBehavior;
22  import dev.metaschema.core.util.ObjectUtils;
23  import dev.metaschema.databind.model.annotations.BoundAssembly;
24  import dev.metaschema.databind.model.annotations.BoundFlag;
25  import dev.metaschema.databind.model.annotations.GroupAs;
26  import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
27  import edu.umd.cs.findbugs.annotations.NonNull;
28  
29  /**
30   * A collection of test scenarios located at a specific path.
31   */
32  @MetaschemaAssembly(
33      formalName = "Test Collection",
34      description = "A collection of test scenarios located at a specific path.",
35      name = "test-collection",
36      moduleClass = MetaschemaTestSuiteModule.class)
37  public class TestCollection implements IBoundObject {
38    private final IMetaschemaData __metaschemaData;
39  
40    /**
41     * A URI reference to the location of this test collection.
42     */
43    @BoundFlag(
44        formalName = "Location",
45        description = "A URI reference to the location of this test collection.",
46        name = "location",
47        required = true,
48        typeAdapter = UriReferenceAdapter.class)
49    private URI _location;
50  
51    /**
52     * The name of this test collection.
53     */
54    @BoundFlag(
55        formalName = "Name",
56        description = "The name of this test collection.",
57        name = "name",
58        required = true,
59        typeAdapter = StringAdapter.class)
60    private String _name;
61  
62    /**
63     * A test scenario that validates a metaschema and its content.
64     */
65    @BoundAssembly(
66        formalName = "Test Scenario",
67        description = "A test scenario that validates a metaschema and its content.",
68        useName = "test-scenario",
69        minOccurs = 1,
70        maxOccurs = -1,
71        groupAs = @GroupAs(name = "test-scenarios", inJson = JsonGroupAsBehavior.LIST))
72    private List<TestScenario> _testScenarios;
73  
74    /**
75     * Constructs a new
76     * {@code dev.metaschema.model.testing.testsuite.TestCollection} instance with
77     * no metadata.
78     */
79    public TestCollection() {
80      this(null);
81    }
82  
83    /**
84     * Constructs a new
85     * {@code dev.metaschema.model.testing.testsuite.TestCollection} instance with
86     * the specified metadata.
87     *
88     * @param data
89     *          the metaschema data, or {@code null} if none
90     */
91    public TestCollection(IMetaschemaData data) {
92      this.__metaschemaData = data;
93    }
94  
95    @Override
96    public IMetaschemaData getMetaschemaData() {
97      return __metaschemaData;
98    }
99  
100   /**
101    * Get the location.
102    *
103    * <p>
104    * A URI reference to the location of this test collection.
105    *
106    * @return the location value
107    */
108   @NonNull
109   public URI getLocation() {
110     return _location;
111   }
112 
113   /**
114    * Set the location.
115    *
116    * <p>
117    * A URI reference to the location of this test collection.
118    *
119    * @param value
120    *          the location value to set
121    */
122   public void setLocation(@NonNull URI value) {
123     _location = value;
124   }
125 
126   /**
127    * Get the name.
128    *
129    * <p>
130    * The name of this test collection.
131    *
132    * @return the name value
133    */
134   @NonNull
135   public String getName() {
136     return _name;
137   }
138 
139   /**
140    * Set the name.
141    *
142    * <p>
143    * The name of this test collection.
144    *
145    * @param value
146    *          the name value to set
147    */
148   public void setName(@NonNull String value) {
149     _name = value;
150   }
151 
152   /**
153    * Get the test Scenario.
154    *
155    * <p>
156    * A test scenario that validates a metaschema and its content.
157    *
158    * @return the test-scenario value
159    */
160   @NonNull
161   public List<TestScenario> getTestScenarios() {
162     if (_testScenarios == null) {
163       _testScenarios = new LinkedList<>();
164     }
165     return ObjectUtils.notNull(_testScenarios);
166   }
167 
168   /**
169    * Set the test Scenario.
170    *
171    * <p>
172    * A test scenario that validates a metaschema and its content.
173    *
174    * @param value
175    *          the test-scenario value to set
176    */
177   public void setTestScenarios(@NonNull List<TestScenario> value) {
178     _testScenarios = value;
179   }
180 
181   /**
182    * Add a new {@link TestScenario} item to the underlying collection.
183    *
184    * @param item
185    *          the item to add
186    * @return {@code true}
187    */
188   public boolean addTestScenario(TestScenario item) {
189     TestScenario value = ObjectUtils.requireNonNull(item, "item cannot be null");
190     if (_testScenarios == null) {
191       _testScenarios = new LinkedList<>();
192     }
193     return _testScenarios.add(value);
194   }
195 
196   /**
197    * Remove the first matching {@link TestScenario} item from the underlying
198    * collection.
199    *
200    * @param item
201    *          the item to remove
202    * @return {@code true} if the item was removed or {@code false} otherwise
203    */
204   public boolean removeTestScenario(TestScenario item) {
205     TestScenario value = ObjectUtils.requireNonNull(item, "item cannot be null");
206     return _testScenarios != null && _testScenarios.remove(value);
207   }
208 
209   @Override
210   public String toString() {
211     return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
212   }
213 }