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:
  • Method Details

    • columnNames

      public List<String> columnNames()
      Description copied from interface: IHeaderTable
      Gets the names of each column.
      Specified by:
      columnNames in interface IHeaderTable<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 interface IHeaderTable<T>
      Overrides:
      columnToIndex in class AbstractHeaderTable<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 interface IHeaderTable<T>
      Overrides:
      hasColumn in class AbstractHeaderTable<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 interface IHeaderTable<T>
      Returns:
      All rows.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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.