Class DataColumn<T>
java.lang.Object
com.github.martincooper.datatable.DataColumn<T>
- All Implemented Interfaces:
IDataColumn,IModifiable<Integer,,Object, IDataColumn> IModifiableByIndex<Object,IDataColumn>
DataColumn. Handles the data for a single column.
Created by Martin Cooper on 08/07/2017.
-
Constructor Summary
ConstructorsConstructorDescriptionDataColumn(Class<T> type, String columnName) DataColumn constructor.DataColumn(Class<T> type, String columnName, io.vavr.collection.Vector<T> data) DataColumn constructor.DataColumn constructor.DataColumn(Class<T> type, String columnName, T[] data) DataColumn constructor. -
Method Summary
Modifier and TypeMethodDescriptionio.vavr.control.Try<IDataColumn>Attempts to add / append a new item to the end of the column.io.vavr.control.Try<DataColumn<T>>Adds / Appends and item to the end of the column.<V> io.vavr.control.Try<DataColumn<V>>Returns the generic data column as it's typed implementation.io.vavr.control.Try<IDataColumn>buildFromRows(io.vavr.collection.Seq<Integer> rowIndexes) Builds a new DataColumn from the data at the specified row indexes.io.vavr.collection.Vector<T>data()Returns the underlying data.io.vavr.control.Try<IDataColumn>Attempts to insert a new item into the column.io.vavr.control.Try<DataColumn<T>>insertItem(Integer index, T value) Inserts the item at the specified index.booleanChecks if the data column supports comparable for sorting.name()Gets the column name.io.vavr.control.Try<IDataColumn>Attempts to remove an existing item at the specified index.io.vavr.control.Try<DataColumn<T>>removeItem(Integer index) Removes the item at the specified index.io.vavr.control.Try<IDataColumn>Attempts to replace an existing item with a new item in the column.io.vavr.control.Try<DataColumn<T>>replaceItem(Integer index, T value) Replaces the existing item at the specified index with the new item.type()Gets the column type.Returns the value at the specified index.
-
Constructor Details
-
DataColumn
DataColumn constructor.- Parameters:
type- Stores the type of data stored in this column.columnName- The column name.
-
DataColumn
DataColumn constructor.- Parameters:
type- Stores the type of data stored in this column.columnName- The column name.data- The data items stored in the column.
-
DataColumn
DataColumn constructor.- Parameters:
type- Stores the type of data stored in this column.columnName- The column name.data- The data items stored in the column.
-
DataColumn
DataColumn constructor.- Parameters:
type- Stores the type of data stored in this column.columnName- The column name.data- The data items stored in the column.
-
-
Method Details
-
name
Gets the column name.- Specified by:
namein interfaceIDataColumn- Returns:
- Returns the column name.
-
type
Gets the column type.- Specified by:
typein interfaceIDataColumn- Returns:
- Returns the column type.
-
data
Returns the underlying data.- Specified by:
datain interfaceIDataColumn- Returns:
- Returns access to the underlying data.
-
valueAt
Returns the value at the specified index.- Specified by:
valueAtin interfaceIDataColumn- Parameters:
rowIndex- The row index.- Returns:
- Returns the value.
-
asType
Returns the generic data column as it's typed implementation. If the types don't match, then it'll return Failure.- Specified by:
asTypein interfaceIDataColumn- Type Parameters:
V- The type.- Parameters:
type- The type of the column.- Returns:
- Returns the typed Data Column wrapped in a Try.
-
buildFromRows
Builds a new DataColumn from the data at the specified row indexes.- Specified by:
buildFromRowsin interfaceIDataColumn- Parameters:
rowIndexes- The rows which the new column data is to be built from.- Returns:
- Returns a new IDataColumn with just the rows specified.
-
add
Attempts to add / append a new item to the end of the column. A type check is performed before addition.- Specified by:
addin interfaceIModifiable<Integer,Object, IDataColumn> - Parameters:
value- The item required to be added.- Returns:
- Returns a Success with the new modified DataColumn, or a Failure.
-
insert
Attempts to insert a new item into the column. A type check is performed before insertion.- Specified by:
insertin interfaceIModifiable<Integer,Object, IDataColumn> - Parameters:
index- The index the item is to be inserted at.value- The item required to be inserted.- Returns:
- Returns a Success with the new modified DataColumn, or a Failure.
-
replace
Attempts to replace an existing item with a new item in the column. A type check is performed before replacement.- Specified by:
replacein interfaceIModifiable<Integer,Object, IDataColumn> - Parameters:
index- The index the item is to be replaced at.value- The new item.- Returns:
- Returns a Success with the new modified DataColumn, or a Failure.
-
remove
Attempts to remove an existing item at the specified index.- Specified by:
removein interfaceIModifiable<Integer,Object, IDataColumn> - Parameters:
index- The index to remove the item at.- Returns:
- Returns a Success with the new modified DataColumn, or a Failure.
-
addItem
Adds / Appends and item to the end of the column.- Parameters:
value- The value to append.- Returns:
- Returns a new DataColumn with the new item appended.
-
insertItem
Inserts the item at the specified index.- Parameters:
index- The index to insert the item at.value- The item to insert.- Returns:
- Returns a new DataColumn with the new item inserted.
-
replaceItem
Replaces the existing item at the specified index with the new item.- Parameters:
index- The index to replace the existing item.value- The new item to replace the existing one.- Returns:
- Returns a new DataColumn with the specified item replaced.
-
removeItem
Removes the item at the specified index.- Parameters:
index- The index to remove the item at.- Returns:
- Returns a new DataColumn with the specified item removed.
-
IsComparable
public boolean IsComparable()Checks if the data column supports comparable for sorting.- Specified by:
IsComparablein interfaceIDataColumn- Returns:
- Returns true if the type supports Comparable.
-