Class DataRow

java.lang.Object
com.github.martincooper.datatable.DataRow

public class DataRow extends Object
A row of data in the DataTable. Created by Martin Cooper on 08/07/2017.
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.vavr.control.Try<DataRow>
    build(DataTable table, Integer rowIdx)
    Builds an instance of a DataRow.
    Returns the data as an array for this row.
    io.vavr.control.Try<Object>
    get(Integer colIndex)
    Returns the data at the specified column index, returning as an object.
    io.vavr.control.Try<Object>
    get(String colName)
    Returns the data in the specified column name, returning as an object.
    <T> T
    getAs(Class<T> type, Integer idx)
    Returns the value of a particular row column as a specific type.
    <T> T
    getAs(Class<T> type, String colName)
    Returns the value of a particular row column as a specific type.
    Gets the row index.
    Returns the underlying Data Table for this row.
    <T> io.vavr.control.Try<T>
    tryGetAs(Class<T> type, Integer idx)
    Returns the value of a particular row column as a specific type.
    <T> io.vavr.control.Try<T>
    tryGetAs(Class<T> type, String colName)
    Returns the value of a particular row column as a specific type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • table

      public DataTable table()
      Returns the underlying Data Table for this row.
      Returns:
      Returns the Data Table for this row .
    • rowIdx

      public Integer rowIdx()
      Gets the row index.
      Returns:
      Returns the row index.
    • data

      public Object[] data()
      Returns the data as an array for this row.
      Returns:
      Returns the data for this row in an array.
    • get

      public io.vavr.control.Try<Object> get(Integer colIndex)
      Returns the data at the specified column index, returning as an object.
      Parameters:
      colIndex - The column index to return the value of.
      Returns:
      Returns the value of the row at the specified column.
    • get

      public io.vavr.control.Try<Object> get(String colName)
      Returns the data in the specified column name, returning as an object.
      Parameters:
      colName - The column to return the value of.
      Returns:
      Returns the value of the row at the specified column.
    • getAs

      public <T> T getAs(Class<T> type, Integer idx)
      Returns the value of a particular row column as a specific type. This method makes no bounds checks or type checks, so any failures will result in an exception being thrown.
      Type Parameters:
      T - The value type.
      Parameters:
      type - The data type.
      idx - The index of the column.
      Returns:
      Returns the value at the specified index.
    • getAs

      public <T> T getAs(Class<T> type, String colName)
      Returns the value of a particular row column as a specific type. This method makes no bounds checks or type checks, so any failures will result in an exception being thrown.
      Type Parameters:
      T - The value type.
      Parameters:
      type - The data type.
      colName - The name of the column.
      Returns:
      Returns the value at the specified index.
    • tryGetAs

      public <T> io.vavr.control.Try<T> tryGetAs(Class<T> type, Integer idx)
      Returns the value of a particular row column as a specific type. This method performs bounds checks and type checks. Any errors will return a Try.failure.
      Type Parameters:
      T - The value type.
      Parameters:
      type - The data type.
      idx - The index of the column.
      Returns:
      Returns the value at the specified index.
    • tryGetAs

      public <T> io.vavr.control.Try<T> tryGetAs(Class<T> type, String colName)
      Returns the value of a particular row column as a specific type. This method performs bounds checks and type checks. Any errors will return a Try.failure.
      Type Parameters:
      T - The value type.
      Parameters:
      type - The data type.
      colName - The name of the column.
      Returns:
      Returns the value at the specified index.
    • build

      public static io.vavr.control.Try<DataRow> build(DataTable table, Integer rowIdx)
      Builds an instance of a DataRow. Row Index is validated before creation, returning a Failure on error.
      Parameters:
      table - The DataTable the DataRow is pointing to.
      rowIdx - The row index.
      Returns:
      Returns a DataRow wrapped in a Try.