Package com.vaadin.flow.data.provider
Class AbstractComponentDataGenerator<T>
- java.lang.Object
-
- com.vaadin.flow.data.provider.AbstractComponentDataGenerator<T>
-
- Type Parameters:
T- the data type
- All Implemented Interfaces:
DataGenerator<T>,Serializable
- Direct Known Subclasses:
ComponentDataGenerator
public abstract class AbstractComponentDataGenerator<T> extends Object implements DataGenerator<T>
Abstract class used as base for DataGenerators that need to manage the lifecycle of components, according to what items are requested or destroyed.- Since:
- 1.0.
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractComponentDataGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ComponentcreateComponent(T item)Creates a new component based on the provided item.voiddestroyAllData()Informs theDataGeneratorthat all data has been dropped.voiddestroyData(T item)Informs theDataGeneratorthat the given data item has been dropped and is no longer needed.protected abstract ElementgetContainer()Gets the element where the generated components will be attached to.protected abstract StringgetItemKey(T item)Gets a unique key for a given item.protected ComponentgetRenderedComponent(String itemKey)voidrefreshData(T item)Informs theDataGeneratorthat a data object has been updated.protected voidregisterRenderedComponent(String itemKey, Component component)Appends the component to the container and registers it for future use during the lifecycle of the generator.protected ComponentupdateComponent(Component currentComponent, T item)Updates an existing component after the item has been updated.-
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.DataGenerator
generateData
-
-
-
-
Method Detail
-
refreshData
public void refreshData(T item)
Description copied from interface:DataGeneratorInforms theDataGeneratorthat a data object has been updated. This method should update any unneeded information stored for given item.- Specified by:
refreshDatain interfaceDataGenerator<T>- Parameters:
item- the updated item
-
destroyData
public void destroyData(T item)
Description copied from interface:DataGeneratorInforms theDataGeneratorthat the given data item has been dropped and is no longer needed. This method should clean up any unneeded information stored for this item.- Specified by:
destroyDatain interfaceDataGenerator<T>- Parameters:
item- the dropped data item
-
destroyAllData
public void destroyAllData()
Description copied from interface:DataGeneratorInforms theDataGeneratorthat all data has been dropped. This method should clean up any unneeded information stored for items.- Specified by:
destroyAllDatain interfaceDataGenerator<T>
-
getContainer
protected abstract Element getContainer()
Gets the element where the generated components will be attached to.- Returns:
- the container
-
createComponent
protected abstract Component createComponent(T item)
Creates a new component based on the provided item.- Parameters:
item- the data item, possiblynull- Returns:
- a
Componentwhich represents the provided item
-
updateComponent
protected Component updateComponent(Component currentComponent, T item)
Updates an existing component after the item has been updated. By default, it creates a new component instance viacreateComponent(Object).- Parameters:
currentComponent- the current component used to represent the item, notnullitem- the updated item- Returns:
- the component that should represent the updated item, not
null
-
getItemKey
protected abstract String getItemKey(T item)
Gets a unique key for a given item. Items with the same keys are considered equal.- Parameters:
item- the model item- Returns:
- a unique key for the item
-
registerRenderedComponent
protected void registerRenderedComponent(String itemKey, Component component)
Appends the component to the container and registers it for future use during the lifecycle of the generator.- Parameters:
itemKey- the key of the model itemcomponent- the component to be attached to the container
-
-