Class DataColumnCollection

java.lang.Object
com.github.martincooper.datatable.DataColumnCollection
All Implemented Interfaces:
IModifiable<Integer,IDataColumn,DataTable>, IModifiableByColumn<DataTable>, IModifiableByIndex<IDataColumn,DataTable>, IModifiableByName<IDataColumn,DataTable>, Iterable<IDataColumn>

public class DataColumnCollection extends Object implements IModifiableByColumn<DataTable>, Iterable<IDataColumn>
DataColumnCollection. Handles a collection of Data Columns. Created by Martin Cooper on 13/07/2017.
  • Method Details

    • iterator

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

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

      public io.vavr.control.Try<IDataColumn> tryGet(int index)
      Returns the IDataColumn at the specified index. Performs bounds check, returns results in a Try.
      Parameters:
      index - The index to return the IDataColumn.
      Returns:
      Returns the IDataColumn.
    • get

      public IDataColumn get(int index)
      Returns the IDataColumn at the specified index.
      Parameters:
      index - The index to return the IDataColumn.
      Returns:
      Returns the IDataColumn.
    • tryGet

      public io.vavr.control.Try<IDataColumn> tryGet(String columnName)
      Returns the IDataColumn by name. Performs column name check, returns results in a Try.
      Parameters:
      columnName - The name of the IDataColumn.
      Returns:
      Returns the IDataColumn.
    • get

      public IDataColumn get(String columnName)
      Returns the IDataColumn by name.
      Parameters:
      columnName - The name of the IDataColumn.
      Returns:
      Returns the IDataColumn.
    • count

      public int count()
      The number of columns in the collection.
      Returns:
      Returns the size of the columns collection.
    • add

      public io.vavr.control.Try<DataTable> add(IDataColumn newColumn)
      Adds a IDataColumn to the column collection.
      Specified by:
      add in interface IModifiable<Integer,IDataColumn,DataTable>
      Parameters:
      newColumn - The new columns to add.
      Returns:
      Returns a new DataTable with the item added.
    • replace

      public io.vavr.control.Try<DataTable> replace(Integer index, IDataColumn newColumn)
      Replaces the column at the specified index with the new column.
      Specified by:
      replace in interface IModifiable<Integer,IDataColumn,DataTable>
      Parameters:
      index - The index of the item to be replaced.
      newColumn - The new column.
      Returns:
      Returns a new collection with the column replaced.
    • insert

      public io.vavr.control.Try<DataTable> insert(Integer index, IDataColumn newColumn)
      Inserts a new column at the specified index.
      Specified by:
      insert in interface IModifiable<Integer,IDataColumn,DataTable>
      Parameters:
      index - The column index to inserted the column at.
      newColumn - The new column.
      Returns:
      Returns a new collection with the column inserted.
    • remove

      public io.vavr.control.Try<DataTable> remove(Integer index)
      Removes the specified column.
      Specified by:
      remove in interface IModifiable<Integer,IDataColumn,DataTable>
      Parameters:
      index - The index of the column to be removed.
      Returns:
      Returns a new collection with the column removed.
    • replace

      public io.vavr.control.Try<DataTable> replace(String columnName, IDataColumn newColumn)
      Replaces the old column with the new column.
      Specified by:
      replace in interface IModifiableByName<IDataColumn,DataTable>
      Parameters:
      columnName - The column to be replaced.
      newColumn - The new column.
      Returns:
      Returns a new collection with the column replaced.
    • insert

      public io.vavr.control.Try<DataTable> insert(String columnName, IDataColumn newColumn)
      Inserts a column after an existing column.
      Specified by:
      insert in interface IModifiableByName<IDataColumn,DataTable>
      Parameters:
      columnName - The column to be inserted after.
      newColumn - The new column.
      Returns:
      Returns a new collection with the column inserted.
    • remove

      public io.vavr.control.Try<DataTable> remove(String columnName)
      Removes a named column.
      Specified by:
      remove in interface IModifiableByName<IDataColumn,DataTable>
      Parameters:
      columnName - The name of the column to be removed.
      Returns:
      Returns a new collection with the column removed.
    • replace

      public io.vavr.control.Try<DataTable> replace(IDataColumn oldColumn, IDataColumn newColumn)
      Replaces the old column with the new column.
      Specified by:
      replace in interface IModifiableByColumn<DataTable>
      Parameters:
      oldColumn - The column to be replaced.
      newColumn - The new column.
      Returns:
      Returns a new collection with the column replaced.
    • insert

      public io.vavr.control.Try<DataTable> insert(IDataColumn currentColumn, IDataColumn newColumn)
      Inserts a new column after the specified column.
      Specified by:
      insert in interface IModifiableByColumn<DataTable>
      Parameters:
      currentColumn - The column to be inserted after.
      newColumn - The new column.
      Returns:
      Returns a new collection with the column inserted.
    • remove

      public io.vavr.control.Try<DataTable> remove(IDataColumn columnToRemove)
      Removes the specified column.
      Specified by:
      remove in interface IModifiableByColumn<DataTable>
      Parameters:
      columnToRemove - The column to be removed.
      Returns:
      Returns a new collection with the column removed.