Package org.djutils.data
Class ListTable
- java.lang.Object
-
- org.djutils.data.Table
-
- org.djutils.data.ListTable
-
- All Implemented Interfaces:
Iterable<Row>,Identifiable
public class ListTable extends Table
Table implementation that storesRecords in aList.Copyright (c) 2020-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUTILS License.- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Constructor Summary
Constructors Constructor Description ListTable(String id, String description, Collection<Column<?>> columns)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRow(Object[] data)Adds a row to the table.voidaddRow(Map<Column<?>,Object> data)Adds a row to the table.voidaddRowByColumnIds(Map<String,Object> data)Adds a row to the table.booleanisEmpty()Returns whether the table is empty.Iterator<Row>iterator()-
Methods inherited from class org.djutils.data.Table
getColumn, getColumnDataTypes, getColumnDataTypeStrings, getColumnDescriptions, getColumnIds, getColumnNumber, getColumnNumber, getColumns, getDescription, getId, getNumberOfColumns, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ListTable
public ListTable(String id, String description, Collection<Column<?>> columns)
Constructor.- Parameters:
id- String; iddescription- String; descriptioncolumns- Collection<Column<?>>; columns
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Returns whether the table is empty.
-
addRow
public void addRow(Map<Column<?>,Object> data)
Adds a row to the table.- Parameters:
data- Map<String, Object>; data with values given per column- Throws:
IllegalArgumentException- when the size or data types in the data map do not comply to the columns
-
addRowByColumnIds
public void addRowByColumnIds(Map<String,Object> data)
Adds a row to the table.- Parameters:
data- Map<String, Object>; data with values given per column id- Throws:
IllegalArgumentException- when the size or data types in the data map do not comply to the columns
-
addRow
public void addRow(Object[] data)
Adds a row to the table. The order in which the elements in the array are offered should be the same as the order of the columns.- Parameters:
data- Object[]; row data- Throws:
IllegalArgumentException- when the size, order or data types in theObject[]do not comply to the columns
-
-