Package com.vaadin.flow.data.provider
Class AbstractDataProvider<T,F>
java.lang.Object
com.vaadin.flow.data.provider.AbstractDataProvider<T,F>
- Type Parameters:
T
- data typeF
- filter type
- All Implemented Interfaces:
DataProvider<T,
,F> Serializable
- Direct Known Subclasses:
AbstractBackEndDataProvider
,AbstractHierarchicalDataProvider
,ListDataProvider
Abstract data provider implementation which takes care of refreshing data
from the underlying data provider.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddDataProviderListener
(DataProviderListener<T> listener) Adds a data provider listener.protected <E> Registration
addListener
(Class<E> eventType, SerializableConsumer<E> method) Registers a new listener with the specified activation method to listen events generated by this component.protected void
fireEvent
(EventObject event) Sends the event to all listeners.void
Refreshes all data based on currently available data in the underlying provider.void
refreshItem
(T item) Refreshes the given item.void
refreshItem
(T item, boolean refreshChildren) Refreshes the given item and all of the children of the item as well.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.data.provider.DataProvider
fetch, getId, isInMemory, size, withConfigurableFilter, withConfigurableFilter, withConvertedFilter
-
Constructor Details
-
AbstractDataProvider
public AbstractDataProvider()
-
-
Method Details
-
addDataProviderListener
Description copied from interface:DataProvider
Adds a data provider listener. The listener is called when some piece of data is updated.The
DataProvider.refreshAll()
method firesDataChangeEvent
each time when it's called. It allows to update UI components when user changes something in the underlying data.- Specified by:
addDataProviderListener
in interfaceDataProvider<T,
F> - Parameters:
listener
- the data change listener, not null- Returns:
- a registration for the listener
- See Also:
-
refreshAll
public void refreshAll()Description copied from interface:DataProvider
Refreshes all data based on currently available data in the underlying provider.- Specified by:
refreshAll
in interfaceDataProvider<T,
F>
-
refreshItem
Description copied from interface:DataProvider
Refreshes the given item and all of the children of the item as well.- Specified by:
refreshItem
in interfaceDataProvider<T,
F> - Parameters:
item
- the item to refreshrefreshChildren
- whether or not to refresh child items- See Also:
-
refreshItem
Description copied from interface:DataProvider
Refreshes the given item. This method should be used to inform allDataProviderListeners
that an item has been updated or replaced with a new instance.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 alternativelyDataProvider.getId(Object)
should be implemented to return an appropriate identifier.- Specified by:
refreshItem
in interfaceDataProvider<T,
F> - Parameters:
item
- the item to refresh- See Also:
-
addListener
Registers a new listener with the specified activation method to listen events generated by this component. If the activation method does not have any arguments the event object will not be passed to it when it's called.- Type Parameters:
E
- the event type- Parameters:
eventType
- the type of the listened event. Events of this type or its subclasses activate the listener.method
- the consumer to receive the event.- Returns:
- a registration for the listener
-
fireEvent
Sends the event to all listeners.- Parameters:
event
- the Event to be sent to all listeners.
-