package org.djutils.data; import java.io.Serializable; import org.djunits.Throw; /** * SimpleColumn implements the Column interface with a single value.
*
* Copyright (c) 2020-2022 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See * for project information https://djutils.org. The DJUTILS project is * distributed under a three-clause BSD-style license, which can be found at * https://djutils.org/docs/license.html.
* @author Alexander Verbraeck * @author Peter Knoppers * @author Wouter Schakel * @param the value type */ public class SimpleDataColumn implements DataColumn, Serializable { /** */ private static final long serialVersionUID = 20200229L; /** the column id, preferably without spaces or symbols. */ private final String id; /** the column description. */ private final String description; /** the value type. */ private final Class valueType; /** * Construct a simple, single valued column. * @param id String; the column id, preferably without spaces or symbols * @param description String; the column description * @param valueType Class<T>; the value type */ public SimpleDataColumn(final String id, final String description, final Class valueType) { Throw.whenNull(id, "id cannot be null"); Throw.when(id.length() == 0, IllegalArgumentException.class, "id cannot be empty"); Throw.whenNull(description, "description cannot be null"); Throw.whenNull(valueType, "valueType cannot be null"); this.id = id; this.description = description; this.valueType = valueType; } /** {@inheritDoc} */ @Override public final String getId() { return this.id; } /** {@inheritDoc} */ @Override public final String getDescription() { return this.description; } /** {@inheritDoc} */ @Override public Class getValueType() { return this.valueType; } /** {@inheritDoc} */ @Override public String toString() { return "SimpleDataColumn [id=" + this.id + ", description=" + this.description + ", valueType=" + this.valueType + "]"; } }