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.model.IBoundObject;
017import dev.metaschema.core.model.IMetaschemaData;
018import dev.metaschema.core.model.JsonGroupAsBehavior;
019import dev.metaschema.core.util.ObjectUtils;
020import dev.metaschema.databind.model.annotations.BoundAssembly;
021import dev.metaschema.databind.model.annotations.GroupAs;
022import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
023import edu.umd.cs.findbugs.annotations.NonNull;
024
025/**
026 * The root element containing a collection of test collections.
027 */
028@MetaschemaAssembly(
029    formalName = "Test Suite",
030    description = "The root element containing a collection of test collections.",
031    name = "test-suite",
032    moduleClass = MetaschemaTestSuiteModule.class,
033    rootName = "test-suite")
034public class TestSuite implements IBoundObject {
035  private final IMetaschemaData __metaschemaData;
036
037  /**
038   * A collection of test scenarios located at a specific path.
039   */
040  @BoundAssembly(
041      formalName = "Test Collection",
042      description = "A collection of test scenarios located at a specific path.",
043      useName = "test-collection",
044      minOccurs = 1,
045      maxOccurs = -1,
046      groupAs = @GroupAs(name = "test-collections", inJson = JsonGroupAsBehavior.LIST))
047  private List<TestCollection> _testCollections;
048
049  /**
050   * Constructs a new {@code dev.metaschema.model.testing.testsuite.TestSuite}
051   * instance with no metadata.
052   */
053  public TestSuite() {
054    this(null);
055  }
056
057  /**
058   * Constructs a new {@code dev.metaschema.model.testing.testsuite.TestSuite}
059   * instance with the specified metadata.
060   *
061   * @param data
062   *          the metaschema data, or {@code null} if none
063   */
064  public TestSuite(IMetaschemaData data) {
065    this.__metaschemaData = data;
066  }
067
068  @Override
069  public IMetaschemaData getMetaschemaData() {
070    return __metaschemaData;
071  }
072
073  /**
074   * Get the test Collection.
075   *
076   * <p>
077   * A collection of test scenarios located at a specific path.
078   *
079   * @return the test-collection value
080   */
081  @NonNull
082  public List<TestCollection> getTestCollections() {
083    if (_testCollections == null) {
084      _testCollections = new LinkedList<>();
085    }
086    return ObjectUtils.notNull(_testCollections);
087  }
088
089  /**
090   * Set the test Collection.
091   *
092   * <p>
093   * A collection of test scenarios located at a specific path.
094   *
095   * @param value
096   *          the test-collection value to set
097   */
098  public void setTestCollections(@NonNull List<TestCollection> value) {
099    _testCollections = value;
100  }
101
102  /**
103   * Add a new {@link TestCollection} item to the underlying collection.
104   *
105   * @param item
106   *          the item to add
107   * @return {@code true}
108   */
109  public boolean addTestCollection(TestCollection item) {
110    TestCollection value = ObjectUtils.requireNonNull(item, "item cannot be null");
111    if (_testCollections == null) {
112      _testCollections = new LinkedList<>();
113    }
114    return _testCollections.add(value);
115  }
116
117  /**
118   * Remove the first matching {@link TestCollection} item from the underlying
119   * collection.
120   *
121   * @param item
122   *          the item to remove
123   * @return {@code true} if the item was removed or {@code false} otherwise
124   */
125  public boolean removeTestCollection(TestCollection item) {
126    TestCollection value = ObjectUtils.requireNonNull(item, "item cannot be null");
127    return _testCollections != null && _testCollections.remove(value);
128  }
129
130  @Override
131  public String toString() {
132    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
133  }
134}