Package de.xima.fc.common.data.table
Class ImmutableListHeaderTable<T>
- java.lang.Object
-
- de.xima.fc.common.data.table.AbstractHeaderTable<T>
-
- de.xima.fc.common.data.table.ImmutableListHeaderTable<T>
-
- Type Parameters:
T
- The type of the cell values.
- All Implemented Interfaces:
IHeaderTable<T>
,Serializable
,Iterable<IHeaderTable.ITableRowEntry<T>>
public final class ImmutableListHeaderTable<T> extends AbstractHeaderTable<T> implements Serializable
Immutable implementation ofIHeaderTable
.- Since:
- 8.2.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.xima.fc.common.data.table.IHeaderTable
IHeaderTable.ITableRowEntry<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
columnNames()
Gets the names of each column.int
columnToIndex(String column)
Converts a column name to an index.static <T> IHeaderTable<T>
fromRows(Iterable<? extends Iterable<? extends T>> rows)
Creates a new table from the given rows of cell values.static <T> IHeaderTable<T>
fromRows(Iterable<? extends Iterable<? extends T>> rows, Supplier<? extends T> defaultValue)
Creates a new table from the given rows of cell values.static <T> IHeaderTable<T>
fromRows(Iterable<? extends Iterable<? extends T>> rows, Supplier<? extends T> defaultValue, Function<? super T,String> headerNameExtractor)
Creates a new table from the given rows of cell values.static IHeaderTable<String>
fromRows(Iterable<? extends Iterable<String>> rows, Supplier<String> defaultValue, boolean firstRowIsHeader)
Creates a new table from the given rows of cell values.boolean
hasColumn(String column)
Checks if the table has a column with the given name.List<List<T>>
rows()
Returns all rows;String
toString()
-
Methods inherited from class de.xima.fc.common.data.table.AbstractHeaderTable
cell, cell, columnCount, columnsByIndex, columnsByName, equals, hasColumn, hashCode, hasRow, indexToColumn, row, rowCount, rowIterator, rows, rows
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.xima.fc.common.data.table.IHeaderTable
iterator
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
columnNames
public List<String> columnNames()
Description copied from interface:IHeaderTable
Gets the names of each column.- Specified by:
columnNames
in interfaceIHeaderTable<T>
- Returns:
- The names of each column.
-
columnToIndex
public int columnToIndex(String column)
Description copied from interface:IHeaderTable
Converts a column name to an index.- Specified by:
columnToIndex
in interfaceIHeaderTable<T>
- Overrides:
columnToIndex
in classAbstractHeaderTable<T>
- Parameters:
column
- The column name.- Returns:
- The index of the column.
-
hasColumn
public boolean hasColumn(String column)
Description copied from interface:IHeaderTable
Checks if the table has a column with the given name.- Specified by:
hasColumn
in interfaceIHeaderTable<T>
- Overrides:
hasColumn
in classAbstractHeaderTable<T>
- Parameters:
column
- The name of the column.- Returns:
true
if the table has a column with the given name,false
otherwise.
-
rows
public List<List<T>> rows()
Description copied from interface:IHeaderTable
Returns all rows;- Specified by:
rows
in interfaceIHeaderTable<T>
- Returns:
- All rows.
-
fromRows
public static <T> IHeaderTable<T> fromRows(Iterable<? extends Iterable<? extends T>> rows)
Creates a new table from the given rows of cell values. Uses the column index as the header name. Fills missing cells with null.- Type Parameters:
T
- The type of the cell values.- Parameters:
rows
- The rows of cell values.- Returns:
- A new table from the given rows of cell values.
-
fromRows
public static <T> IHeaderTable<T> fromRows(Iterable<? extends Iterable<? extends T>> rows, Supplier<? extends T> defaultValue)
Creates a new table from the given rows of cell values. Uses the column index as the header name. Fills missing cells with the given default value.- Type Parameters:
T
- The type of the cell values.- Parameters:
rows
- The rows of cell values.defaultValue
- Supplier for the default value for missing cells. When null, null is used as the default value.- Returns:
- A new table from the given rows of cell values.
-
fromRows
public static IHeaderTable<String> fromRows(Iterable<? extends Iterable<String>> rows, Supplier<String> defaultValue, boolean firstRowIsHeader)
Creates a new table from the given rows of cell values. Uses the first row as the names for the header when the first-row-is-header flag is true. Otherwise, uses the column index as the header name. Fills missing cells with the given default value.- Parameters:
rows
- The rows of cell values.defaultValue
- Supplier for the default value for missing cells. When null, null is used as the default value.- Returns:
- A new table from the given rows of cell values.
-
fromRows
public static <T> IHeaderTable<T> fromRows(Iterable<? extends Iterable<? extends T>> rows, Supplier<? extends T> defaultValue, Function<? super T,String> headerNameExtractor)
Creates a new table from the given rows of cell values. When the given header name extractor is non-null, uses the first row as the names for the header. Otherwise, uses the column index as the header name. Fills missing cells with the given default value.- Type Parameters:
T
- The type of the cell values.- Parameters:
rows
- The rows of cell values.defaultValue
- Supplier for the default value for missing cells. When null, null is used as the default value.headerNameExtractor
- Extractor for the header name. When null, the column index is used as the header name.- Returns:
- A new table from the given rows of cell values.
-
-