Class GridListDataView<T>

Type Parameters:
T - data type
All Implemented Interfaces:
DataView<T>, ListDataView<T,AbstractListDataView<T>>, Serializable

public class GridListDataView<T> extends AbstractListDataView<T>
Data view implementation for Grid with in-memory list data. Provides information on the data and allows operations on it.
Since:
See Also:
  • Constructor Details

    • GridListDataView

      public GridListDataView(DataCommunicator<T> dataCommunicator, Grid<T> grid, SerializableBiConsumer<SerializablePredicate<T>,SerializableComparator<T>> filterOrSortingChangedCallback)
      Creates a new instance of Grid in-memory data view and verifies the passed data provider is compatible with this data view implementation.
      Parameters:
      dataCommunicator - the data communicator of the Grid, not null
      grid - the Grid component, not null
      filterOrSortingChangedCallback - callback, which is being invoked when the Grid's filtering or sorting changes, not null
  • Method Details

    • getItems

      public Stream<T> getItems()
      Description copied from interface: DataView
      Get the full data available to the component. Data is filtered and sorted the same way as in the component.

      Consumers of the returned stream are responsible for closing it when all the stream operations are done to ensure that any resources feeding the stream are properly released. Failure to close the stream might lead to resource leaks.

      It is strongly recommended to use a try-with-resources block to automatically close the stream after its terminal operation has been executed. Below is an example of how to properly use and close the stream:

      
       try (Stream<T> stream = dataView.getItems()) {
           stream.forEach(System.out::println); // Example terminal operation
       }
       
      Specified by:
      getItems in interface DataView<T>
      Overrides:
      getItems in class AbstractListDataView<T>
      Returns:
      filtered and sorted data set
    • getItemCount

      public int getItemCount()
      Description copied from interface: ListDataView
      Get the full item count with filters if any set. As the item count might change at any point, it is recommended to add a listener with the DataView.addItemCountChangeListener(ComponentEventListener) method instead to get notified when the item count has changed.
      Specified by:
      getItemCount in interface ListDataView<T,AbstractListDataView<T>>
      Overrides:
      getItemCount in class AbstractListDataView<T>
      Returns:
      filtered item count
      See Also:
    • setIdentifierProvider

      public void setIdentifierProvider(IdentifierProvider<T> identifierProvider)
      Description copied from interface: DataView
      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);.
      Specified by:
      setIdentifierProvider in interface DataView<T>
      Overrides:
      setIdentifierProvider in class AbstractDataView<T>
      Parameters:
      identifierProvider - function that returns the non-null identifier for a given item