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 Summary
Modifier and TypeMethodDescriptionio.vavr.control.Try<DataTable>add(IDataColumn newColumn) Adds a IDataColumn to the column collection.intcount()The number of columns in the collection.get(int index) Returns the IDataColumn at the specified index.Returns the IDataColumn by name.io.vavr.control.Try<DataTable>insert(IDataColumn currentColumn, IDataColumn newColumn) Inserts a new column after the specified column.io.vavr.control.Try<DataTable>insert(Integer index, IDataColumn newColumn) Inserts a new column at the specified index.io.vavr.control.Try<DataTable>insert(String columnName, IDataColumn newColumn) Inserts a column after an existing column.iterator()Returns an iterator over elements of type IDataColumn.<U> io.vavr.collection.Seq<U>map(Function<? super IDataColumn, ? extends U> mapper) Map implementation for the DataColumnCollection class.io.vavr.control.Try<DataTable>remove(IDataColumn columnToRemove) Removes the specified column.io.vavr.control.Try<DataTable>Removes the specified column.io.vavr.control.Try<DataTable>Removes a named column.io.vavr.control.Try<DataTable>replace(IDataColumn oldColumn, IDataColumn newColumn) Replaces the old column with the new column.io.vavr.control.Try<DataTable>replace(Integer index, IDataColumn newColumn) Replaces the column at the specified index with the new column.io.vavr.control.Try<DataTable>replace(String columnName, IDataColumn newColumn) Replaces the old column with the new column.io.vavr.control.Try<IDataColumn>tryGet(int index) Returns the IDataColumn at the specified index.io.vavr.control.Try<IDataColumn>Returns the IDataColumn by name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
iterator
Returns an iterator over elements of type IDataColumn.- Specified by:
iteratorin interfaceIterable<IDataColumn>- Returns:
- an Iterator.
-
map
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
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
Returns the IDataColumn at the specified index.- Parameters:
index- The index to return the IDataColumn.- Returns:
- Returns the IDataColumn.
-
tryGet
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
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
Adds a IDataColumn to the column collection.- Specified by:
addin interfaceIModifiable<Integer,IDataColumn, DataTable> - Parameters:
newColumn- The new columns to add.- Returns:
- Returns a new DataTable with the item added.
-
replace
Replaces the column at the specified index with the new column.- Specified by:
replacein interfaceIModifiable<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
Inserts a new column at the specified index.- Specified by:
insertin interfaceIModifiable<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
Removes the specified column.- Specified by:
removein interfaceIModifiable<Integer,IDataColumn, DataTable> - Parameters:
index- The index of the column to be removed.- Returns:
- Returns a new collection with the column removed.
-
replace
Replaces the old column with the new column.- Specified by:
replacein interfaceIModifiableByName<IDataColumn,DataTable> - Parameters:
columnName- The column to be replaced.newColumn- The new column.- Returns:
- Returns a new collection with the column replaced.
-
insert
Inserts a column after an existing column.- Specified by:
insertin interfaceIModifiableByName<IDataColumn,DataTable> - Parameters:
columnName- The column to be inserted after.newColumn- The new column.- Returns:
- Returns a new collection with the column inserted.
-
remove
Removes a named column.- Specified by:
removein interfaceIModifiableByName<IDataColumn,DataTable> - Parameters:
columnName- The name of the column to be removed.- Returns:
- Returns a new collection with the column removed.
-
replace
Replaces the old column with the new column.- Specified by:
replacein interfaceIModifiableByColumn<DataTable>- Parameters:
oldColumn- The column to be replaced.newColumn- The new column.- Returns:
- Returns a new collection with the column replaced.
-
insert
Inserts a new column after the specified column.- Specified by:
insertin interfaceIModifiableByColumn<DataTable>- Parameters:
currentColumn- The column to be inserted after.newColumn- The new column.- Returns:
- Returns a new collection with the column inserted.
-
remove
Removes the specified column.- Specified by:
removein interfaceIModifiableByColumn<DataTable>- Parameters:
columnToRemove- The column to be removed.- Returns:
- Returns a new collection with the column removed.
-