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 of
IHeaderTable.- Since:
- 8.2.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface IHeaderTable
IHeaderTable.ITableRowEntry<T> -
Method Summary
Modifier and TypeMethodDescriptionGets the names of each column.intcolumnToIndex(String column) Converts a column name to an index.static <T> IHeaderTable<T> Creates a new table from the given rows of cell values.static <T> IHeaderTable<T> 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.booleanChecks if the table has a column with the given name.rows()Returns all rows;toString()Methods inherited from class AbstractHeaderTable
cell, cell, columnCount, columnsByIndex, columnsByName, equals, hasColumn, hashCode, hasRow, indexToColumn, row, rowCount, rowIterator, rows, rowsMethods inherited from interface IHeaderTable
iteratorMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
columnNames
Description copied from interface:IHeaderTableGets the names of each column.- Specified by:
columnNamesin interfaceIHeaderTable<T>- Returns:
- The names of each column.
-
columnToIndex
Description copied from interface:IHeaderTableConverts a column name to an index.- Specified by:
columnToIndexin interfaceIHeaderTable<T>- Overrides:
columnToIndexin classAbstractHeaderTable<T>- Parameters:
column- The column name.- Returns:
- The index of the column.
-
hasColumn
Description copied from interface:IHeaderTableChecks if the table has a column with the given name.- Specified by:
hasColumnin interfaceIHeaderTable<T>- Overrides:
hasColumnin classAbstractHeaderTable<T>- Parameters:
column- The name of the column.- Returns:
trueif the table has a column with the given name,falseotherwise.
-
rows
Description copied from interface:IHeaderTableReturns all rows;- Specified by:
rowsin interfaceIHeaderTable<T>- Returns:
- All rows.
-
toString
-
fromRows
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.
-