com.vaadin.flow.data.provider.
Interface DataView<T>
-
Type Parameters:
T
- data typeAll Superinterfaces:
All Known Subinterfaces:
LazyDataView<T>
,ListDataView<T,V>
All Known Implementing Classes:
AbstractDataView
,AbstractLazyDataView
,AbstractListDataView
,CheckboxGroupDataView
,CheckboxGroupListDataView
,ComboBoxDataView
,ComboBoxLazyDataView
,ComboBoxListDataView
,GridDataView
,GridLazyDataView
,GridListDataView
,ListBoxDataView
,ListBoxListDataView
,RadioButtonGroupDataView
,RadioButtonGroupListDataView
,SelectDataView
,SelectListDataView
public interface DataView<T> extends Serializable
Base view interface for getting information on current data set of a Component.
Since:
-
-
Method Summary
All Methods Modifier and Type Method Description Registration
addItemCountChangeListener(ComponentEventListener<ItemCountChangeEvent<?>> listener)
Add an item count change listener that is fired when the item count changes.
T
getItem(int index)
Gets the item at the given index from the data available to the component.
Stream<T>
getItems()
Get the full data available to the component.
void
refreshAll()
Notifies the component that all the items should be refreshed.
void
refreshItem(T item)
Notifies the component that the item has been updated and thus should be refreshed.
void
setIdentifierProvider(IdentifierProvider<T> identifierProvider)
Sets an identifier provider, which returns an identifier for the given item.
-
-
-
Method Detail
-
getItem
T getItem(int index)
Gets the item at the given index from the data available to the component. Data is filtered and sorted the same way as in the component.
Parameters:
index
- item index numberReturns:
item on index
Throws:
IndexOutOfBoundsException
- requested index is outside of the filtered and sorted data set
-
getItems
Stream<T> getItems()
Get the full data available to the component. Data is filtered and sorted the same way as in the component.
Returns:
filtered and sorted data set
-
refreshItem
void refreshItem(T item)
Notifies the component that the item has been updated and thus should be refreshed.
For this to work properly, the item must either implement
Object.equals(Object)
andObject.hashCode()
to consider both the old and the new item instances to be equal, or alternatively use thesetIdentifierProvider(IdentifierProvider)
to set an appropriate item's identifier.This method delegates the update to
DataProvider.refreshItem(Object)
.Parameters:
item
- item containing updated stateSee Also:
-
refreshAll
void refreshAll()
Notifies the component that all the items should be refreshed.
-
addItemCountChangeListener
Registration addItemCountChangeListener(ComponentEventListener<ItemCountChangeEvent<?>> listener)
Add an item count change listener that is fired when the item count changes. This can happen for instance when filtering the items.
Item count change listener is bound to the component and will be retained even if the data changes by setting of a new items or
DataProvider
to component.NOTE: when the component supports lazy loading (implements
HasLazyDataView
) and a count callback has not been provided, an estimate of the item count is used and increased until the actual count has been reached. When the estimate is used, the event is fired with theItemCountChangeEvent.isItemCountEstimated()
returningtrue
.Parameters:
listener
- item count change listener to registerReturns:
registration for removing the listener
-
setIdentifierProvider
void setIdentifierProvider(IdentifierProvider<T> identifierProvider)
Sets an identifier provider, which returns an identifier for the given item. The identifier is used for comparing the equality of items. Usage example:
dataView.setIdentifiedProvider(Item::getId);
.Parameters:
identifierProvider
- function that returns the non-null identifier for a given item
-
-