Class DataRowCollection

java.lang.Object
com.github.martincooper.datatable.DataRowCollection
All Implemented Interfaces:
Iterable<DataRow>

public class DataRowCollection extends Object
DataRowCollection. Handles a collection of DataRows Created by Martin Cooper on 17/07/2017.
  • Field Details

    • table

      protected final DataTable table
    • rows

      protected final io.vavr.collection.Vector<DataRow> rows
  • Method Details

    • build

      public static DataRowCollection build(DataTable table)
      Builds a new DataRowCollection for the specified DataTable.
      Parameters:
      table - The table to build the DataRowCollection for.
      Returns:
      Returns the DataRowCollection.
    • build

      public static io.vavr.control.Try<DataRowCollection> build(DataTable table, Iterable<DataRow> rows)
      Builds a new DataRowCollection for the specified DataTable.
      Parameters:
      table - The table to build the DataRowCollection for.
      rows - The rows to build the table.
      Returns:
      Returns the DataRowCollection.
    • iterator

      public Iterator<DataRow> iterator()
      Returns an iterator over elements of DataRow.
      Specified by:
      iterator in interface Iterable<DataRow>
      Returns:
      an Iterator.
    • get

      public DataRow get(Integer rowIndex)
      Returns the Data Row at the specified index.
      Parameters:
      rowIndex - The row index.
      Returns:
      Returns the Data Row.
    • rowCount

      public Integer rowCount()
      The number of rows in the collection.
      Returns:
      Returns the number of rows.
    • asSeq

      public io.vavr.collection.Seq<DataRow> asSeq()
      Returns access to the Data Row collection as a sequence of Data Rows.
      Returns:
      Returns the rows.
    • filter

      public DataView filter(Predicate<DataRow> predicate)
      Filters the row data using the specified predicate, returning the results as a DataView over the original table.
      Parameters:
      predicate - The filter criteria.
      Returns:
      Returns a DataView with the filter results.
    • map

      public <U> io.vavr.collection.Seq<U> map(Function<? super DataRow,? extends U> mapper)
      Map implementation for the DataRowCollection class.
      Type Parameters:
      U - Mapped return type.
      Parameters:
      mapper - The map function.
      Returns:
      Returns a sequence of the applied map.
    • flatMap

      public <U> io.vavr.collection.Seq<U> flatMap(Function<? super DataRow,? extends Iterable<? extends U>> mapper)
      FlatMap implementation for the DataRowCollection class.
      Type Parameters:
      U - Mapped return type.
      Parameters:
      mapper - The map function.
      Returns:
      Returns a sequence of the applied flatMap.
    • reduce

      public DataRow reduce(BiFunction<? super DataRow,? super DataRow,? extends DataRow> reducer)
      Reduce implementation for the DataRowCollection class.
      Parameters:
      reducer - The reduce function.
      Returns:
      Returns a single, reduced DataRow.
    • foldLeft

      public <U> U foldLeft(U zero, BiFunction<? super U,? super DataRow,? extends U> folder)
      Fold Left implementation for the DataRowCollection class.
      Type Parameters:
      U - Fold return type.
      Parameters:
      folder - The fold function.
      Returns:
      Returns a single value of U.
    • foldRight

      public <U> U foldRight(U zero, BiFunction<? super DataRow,? super U,? extends U> folder)
      Fold Right implementation for the DataRowCollection class.
      Type Parameters:
      U - Fold return type.
      Parameters:
      folder - The fold function.
      Returns:
      Returns a single value of U.
    • groupBy

      public <C> io.vavr.collection.Map<C,io.vavr.collection.Vector<DataRow>> groupBy(Function<? super DataRow,? extends C> grouper)
      GroupBy implementation for the DataRowCollection class.
      Parameters:
      grouper - The group by function.
      Returns:
      Returns a map containing the grouped data.