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.net.URI;
014import java.util.LinkedList;
015import java.util.List;
016
017import dev.metaschema.core.datatype.adapter.StringAdapter;
018import dev.metaschema.core.datatype.adapter.UriReferenceAdapter;
019import dev.metaschema.core.model.IBoundObject;
020import dev.metaschema.core.model.IMetaschemaData;
021import dev.metaschema.core.model.JsonGroupAsBehavior;
022import dev.metaschema.core.util.ObjectUtils;
023import dev.metaschema.databind.model.annotations.BoundAssembly;
024import dev.metaschema.databind.model.annotations.BoundFlag;
025import dev.metaschema.databind.model.annotations.GroupAs;
026import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
027import edu.umd.cs.findbugs.annotations.NonNull;
028
029/**
030 * A collection of test scenarios located at a specific path.
031 */
032@MetaschemaAssembly(
033    formalName = "Test Collection",
034    description = "A collection of test scenarios located at a specific path.",
035    name = "test-collection",
036    moduleClass = MetaschemaTestSuiteModule.class)
037public class TestCollection implements IBoundObject {
038  private final IMetaschemaData __metaschemaData;
039
040  /**
041   * A URI reference to the location of this test collection.
042   */
043  @BoundFlag(
044      formalName = "Location",
045      description = "A URI reference to the location of this test collection.",
046      name = "location",
047      required = true,
048      typeAdapter = UriReferenceAdapter.class)
049  private URI _location;
050
051  /**
052   * The name of this test collection.
053   */
054  @BoundFlag(
055      formalName = "Name",
056      description = "The name of this test collection.",
057      name = "name",
058      required = true,
059      typeAdapter = StringAdapter.class)
060  private String _name;
061
062  /**
063   * A test scenario that validates a metaschema and its content.
064   */
065  @BoundAssembly(
066      formalName = "Test Scenario",
067      description = "A test scenario that validates a metaschema and its content.",
068      useName = "test-scenario",
069      minOccurs = 1,
070      maxOccurs = -1,
071      groupAs = @GroupAs(name = "test-scenarios", inJson = JsonGroupAsBehavior.LIST))
072  private List<TestScenario> _testScenarios;
073
074  /**
075   * Constructs a new
076   * {@code dev.metaschema.model.testing.testsuite.TestCollection} instance with
077   * no metadata.
078   */
079  public TestCollection() {
080    this(null);
081  }
082
083  /**
084   * Constructs a new
085   * {@code dev.metaschema.model.testing.testsuite.TestCollection} instance with
086   * the specified metadata.
087   *
088   * @param data
089   *          the metaschema data, or {@code null} if none
090   */
091  public TestCollection(IMetaschemaData data) {
092    this.__metaschemaData = data;
093  }
094
095  @Override
096  public IMetaschemaData getMetaschemaData() {
097    return __metaschemaData;
098  }
099
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}