Class AbstractDataView<T>

    • Constructor Detail

      • AbstractDataView

        public AbstractDataView​(SerializableSupplier<? extends DataProvider<T,​?>> dataProviderSupplier,
                                Component component)
        Creates a new instance of AbstractDataView subclass and verifies the passed data provider is compatible with this data view implementation.
        Parameters:
        dataProviderSupplier - supplier from which the DataProvider can be gotten
        component - the component that the dataView is bound to
    • Method Detail

      • addItemCountChangeListener

        public Registration addItemCountChangeListener​(ComponentEventListener<ItemCountChangeEvent<?>> listener)
        Description copied from interface: DataView
        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 the ItemCountChangeEvent.isItemCountEstimated() returning true.

        Specified by:
        addItemCountChangeListener in interface DataView<T>
        Parameters:
        listener - item count change listener to register
        Returns:
        registration for removing the listener
      • getSupportedDataProviderType

        protected abstract Class<?> getSupportedDataProviderType()
        Returns supported DataProvider type for this DataView.
        Returns:
        supported data provider type
      • verifyDataProviderType

        protected final void verifyDataProviderType​(Class<?> dataProviderType)
        Verifies an obtained DataProvider type is appropriate for current Data View type.
        Parameters:
        dataProviderType - data provider type to be verified
        Throws:
        IllegalStateException - if data provider type is incompatible with data view type
      • 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.
        Specified by:
        getItems in interface DataView<T>
        Returns:
        filtered and sorted data set
      • refreshAll

        public void refreshAll()
        Description copied from interface: DataView
        Notifies the component that all the items should be refreshed.
        Specified by:
        refreshAll in interface DataView<T>
      • 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>
        Parameters:
        identifierProvider - function that returns the non-null identifier for a given item
      • addIdentifierProviderChangeListener

        public Registration addIdentifierProviderChangeListener​(ComponentEventListener<IdentifierProviderChangeEvent<T,​?>> listener)
        Add an identifier provider change listener that is fired when a custom identifier provider is set with setIdentifierProvider(IdentifierProvider).

        Can be used by components to get notified that a new identifier provider has been set through the data view.

        Parameters:
        listener - identifier provider change listener to register
        Returns:
        registration for removing the listener
      • equals

        protected boolean equals​(T item,
                                 T compareTo)