View Javadoc
1   package org.opentrafficsim.kpi.sampling;
2   
3   import java.util.Collection;
4   
5   import org.djunits.Throw;
6   import org.djutils.immutablecollections.ImmutableArrayList;
7   import org.djutils.immutablecollections.ImmutableList;
8   
9   /**
10   * Abstract {@code Table} implementation taking care of the columns.
11   * <p>
12   * Copyright (c) 2020-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13   * BSD-style license. See <a href="https://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
14   * </p>
15   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
16   * @author <a href="https://www.tudelft.nl/pknoppers">Peter Knoppers</a>
17   * @author <a href="https://www.transport.citg.tudelft.nl">Wouter Schakel</a>
18   */
19  public abstract class AbstractTable implements Table
20  {
21  
22      /** Id. */
23      private final String id;
24      
25      /** Description. */
26      private final String description;
27      
28      /** Columns. */
29      private final ImmutableList<Column<?>> columns;
30      
31      /**
32       * Constructor.
33       * @param id String; id
34       * @param description String; description
35       * @param columns Collection&lt;Column&lt;?&gt;&gt;; columns
36       */
37      public AbstractTable(final String id, final String description, final Collection<Column<?>> columns)
38      {
39          Throw.whenNull(id, "Id may not be null.");
40          Throw.whenNull(description, "Description may not be null.");
41          this.id = id;
42          this.description = description;
43          this.columns = new ImmutableArrayList<>(columns);
44      }
45      
46      /** {@inheritDoc} */
47      @Override
48      public ImmutableList<Column<?>> getColumns()
49      {
50          return this.columns;
51      }
52  
53      /** {@inheritDoc} */
54      @Override
55      public String getId()
56      {
57          return this.id;
58      }
59  
60      /** {@inheritDoc} */
61      @Override
62      public String getDescription()
63      {
64          return this.description;
65      }
66      
67  }