Class DataRowCollectionModifiable

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

public class DataRowCollectionModifiable extends Object
DataRowCollectionModifiable. 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

    • addValues

      public io.vavr.control.Try<DataTable> addValues(Object... rowValues)
      Returns a new DataTable with the additional row appended.
      Parameters:
      rowValues - The values to append to the row.
      Returns:
      Returns a new DataTable with the row appended.
    • add

      public io.vavr.control.Try<DataTable> add(Object[] rowValues)
      Returns a new DataTable with the additional row appended.
      Parameters:
      rowValues - The values to append to the row.
      Returns:
      Returns a new DataTable with the row appended.
    • insertValues

      public io.vavr.control.Try<DataTable> insertValues(int idx, Object... rowValues)
      Returns a new DataTable with the additional row inserted at the specified index.
      Parameters:
      idx - The row index.
      rowValues - The values to insert into the row.
      Returns:
      Returns a new DataTable with the row inserted.
    • insert

      public io.vavr.control.Try<DataTable> insert(int idx, Object[] rowValues)
      Returns a new DataTable with the additional row inserted at the specified index.
      Parameters:
      idx - The row index.
      rowValues - The values to insert into the row.
      Returns:
      Returns a new DataTable with the row inserted.
    • replaceValues

      public io.vavr.control.Try<DataTable> replaceValues(int idx, Object... rowValues)
      Returns a new DataTable with the data replaced at the specified index.
      Parameters:
      idx - The row index.
      rowValues - The new values to replaced the old ones.
      Returns:
      Returns a new DataTable with the row inserted.
    • replace

      public io.vavr.control.Try<DataTable> replace(int idx, Object[] rowValues)
      Returns a new DataTable with the data replaced at the specified index.
      Parameters:
      idx - The row index.
      rowValues - The new values to replaced the old ones.
      Returns:
      Returns a new DataTable with the row inserted.
    • remove

      public io.vavr.control.Try<DataTable> remove(int idx)
      Returns a new DataTable with the specified row removed.
      Parameters:
      idx - The row index.
      Returns:
      Returns a new DataTable with the row removed.
    • build

      public static DataRowCollectionModifiable build(DataTable table)
      Builds a new DataRowCollection for the specified DataTable.
      Parameters:
      table - The table to build the DataRowCollection for.
      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.