public class ListDataSource<T> extends Object implements DataSource<T>
Usage:
ListDataSource<Integer> ds = new ListDataSource<Integer>(1, 2, 3, 4); // Add item to the data source ds.asList().add(5); // Remove item from the data source ds.asList().remove(3); // Add multiple items ds.asList().addAll(Arrays.asList(5, 6, 7));
DataSource.RowHandle<T>| Constructor and Description |
|---|
ListDataSource(List<T> datasource)
Constructs a new list data source.
|
ListDataSource(T... rows)
Constructs a data source with a set of rows.
|
| Modifier and Type | Method and Description |
|---|---|
com.vaadin.shared.Registration |
addDataChangeHandler(DataChangeHandler dataChangeHandler) |
List<T> |
asList()
Gets the list that backs this datasource.
|
void |
ensureAvailability(int firstRowIndex,
int numberOfRows) |
DataSource.RowHandle<T> |
getHandle(T row) |
T |
getRow(int rowIndex) |
SelectAllHandler<T> |
getSelectAllHandler()
Returns a
SelectAllHandler for this ListDataSource. |
int |
indexOf(T row)
Retrieves the index for given row object.
|
boolean |
isWaitingForData() |
int |
size() |
void |
sort(Comparator<T> comparator)
Sort entire container according to a
Comparator. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddDataChangeHandlerpublic ListDataSource(List<T> datasource)
Note: Modifications to the original list will not be reflected in the
data source after the data source has been constructed. To add or remove
items to the data source after it has been constructed use
asList().
datasource - The list to use for providing the data to the gridpublic void ensureAvailability(int firstRowIndex,
int numberOfRows)
ensureAvailability in interface DataSource<T>public T getRow(int rowIndex)
getRow in interface DataSource<T>public int size()
size in interface DataSource<T>public com.vaadin.shared.Registration addDataChangeHandler(DataChangeHandler dataChangeHandler)
addDataChangeHandler in interface DataSource<T>public List<T> asList()
Note: The list is not the same list as passed into the data source via the constructor.
public DataSource.RowHandle<T> getHandle(T row) throws IllegalStateException
getHandle in interface DataSource<T>IllegalStateExceptionpublic void sort(Comparator<T> comparator)
Comparator.comparator - a comparator object, which compares two data source entries
(beans/pojos)public int indexOf(T row)
Note: This method does not verify that the given row object exists at all in this DataSource.
row - the row object-1 if row is not availablepublic SelectAllHandler<T> getSelectAllHandler()
SelectAllHandler for this ListDataSource.public boolean isWaitingForData()
isWaitingForData in interface DataSource<T>Copyright © 2021 Vaadin Ltd. All rights reserved.