Interface InMemoryDataProvider<T>

    • Method Detail

      • isInMemory

        default boolean isInMemory()
        Description copied from interface: DataProvider
        Gets whether the DataProvider content all available in memory or does it use some external backend.
        Specified by:
        isInMemory in interface DataProvider<T,​SerializablePredicate<T>>
        Returns:
        true if all data is in memory; false if not
      • getFilter

        SerializablePredicate<T> getFilter()
        Gets the current filter of this data provider.
        Returns:
        the filter of this data provider
      • getSortComparator

        SerializableComparator<T> getSortComparator()
        Gets the current sort comparator of this data provider.
        Returns:
        the sort comparator of this data provider
      • setSortComparator

        void setSortComparator​(SerializableComparator<T> comparator)
        Sets the comparator to use as the default sorting for this data provider. This overrides the sorting set by any other method that manipulates the default sorting of this data provider.

        The default sorting is used if the query defines no sorting. The default sorting is also used to determine the ordering of items that are considered equal by the sorting defined in the query.

        Parameters:
        comparator - a comparator to use, or null to clear any previously set sort order
        See Also:
        setSortOrder(ValueProvider, SortDirection), addSortComparator(SerializableComparator)
      • addSortComparator

        default void addSortComparator​(SerializableComparator<T> comparator)
        Adds a comparator to the default sorting for this data provider. If no default sorting has been defined, then the provided comparator will be used as the default sorting. If a default sorting has been defined, then the provided comparator will be used to determine the ordering of items that are considered equal by the previously defined default sorting.

        The default sorting is used if the query defines no sorting. The default sorting is also used to determine the ordering of items that are considered equal by the sorting defined in the query.

        Parameters:
        comparator - a comparator to add, not null
        See Also:
        setSortComparator(SerializableComparator), addSortOrder(ValueProvider, SortDirection)
      • setSortOrder

        default <V extends Comparable<? super V>> void setSortOrder​(ValueProvider<T,​V> valueProvider,
                                                                    SortDirection sortDirection)
        Sets the property and direction to use as the default sorting for this data provider. This overrides the sorting set by any other method that manipulates the default sorting of this data provider.

        The default sorting is used if the query defines no sorting. The default sorting is also used to determine the ordering of items that are considered equal by the sorting defined in the query.

        Type Parameters:
        V - the provided value type
        Parameters:
        valueProvider - the value provider that defines the property do sort by, not null
        sortDirection - the sort direction to use, not null
        See Also:
        setSortComparator(SerializableComparator), addSortOrder(ValueProvider, SortDirection)
      • addSortOrder

        default <V extends Comparable<? super V>> void addSortOrder​(ValueProvider<T,​V> valueProvider,
                                                                    SortDirection sortDirection)
        Adds a property and direction to the default sorting for this data provider. If no default sorting has been defined, then the provided sort order will be used as the default sorting. If a default sorting has been defined, then the provided sort order will be used to determine the ordering of items that are considered equal by the previously defined default sorting.

        The default sorting is used if the query defines no sorting. The default sorting is also used to determine the ordering of items that are considered equal by the sorting defined in the query.

        Type Parameters:
        V - the provided value type
        Parameters:
        valueProvider - the value provider that defines the property do sort by, not null
        sortDirection - the sort direction to use, not null
        See Also:
        setSortOrder(ValueProvider, SortDirection), addSortComparator(SerializableComparator)
      • filteringBy

        default <Q> DataProvider<T,​Q> filteringBy​(SerializableBiPredicate<T,​Q> predicate)
        Wraps this data provider to create a new data provider that is filtered by comparing an item to the filter value provided in the query.

        The predicate receives the item as the first parameter and the query filter value as the second parameter, and should return true if the corresponding item should be included. The query filter value is never null – all items are included without running the predicate if the query doesn't define any filter.

        Type Parameters:
        Q - the filter type
        Parameters:
        predicate - a predicate to use for comparing the item to the query filter, not null
        Returns:
        a data provider that filters accordingly, not null
      • filteringBy

        default <V,​Q> DataProvider<T,​Q> filteringBy​(ValueProvider<T,​V> valueProvider,
                                                                SerializableBiPredicate<V,​Q> predicate)
        Wraps this data provider to create a new data provider that is filtered by comparing an item property value to the filter value provided in the query.

        The predicate receives the property value as the first parameter and the query filter value as the second parameter, and should return true if the corresponding item should be included. The query filter value is never null – all items are included without running either callback if the query doesn't define any filter.

        Type Parameters:
        V - the provided value type
        Q - the filter type
        Parameters:
        valueProvider - a value provider that gets the property value, not null
        predicate - a predicate to use for comparing the property value to the query filter, not null
        Returns:
        a data provider that filters accordingly, not null
      • filteringByEquals

        default <V> DataProvider<T,​V> filteringByEquals​(ValueProvider<T,​V> valueProvider)
        Wraps this data provider to create a new data provider that is filtered by testing whether the value of a property is equals to the filter value provided in the query. Equality is tested using Objects.equals(Object, Object).
        Type Parameters:
        V - the provided value type
        Parameters:
        valueProvider - a value provider that gets the property value, not null
        Returns:
        a data provider that filters accordingly, not null
      • filteringBySubstring

        default DataProvider<T,​String> filteringBySubstring​(ValueProvider<T,​String> valueProvider,
                                                                  Locale locale)
        Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of the filter value provided in the query is a substring of the lower case representation of an item property value. The filter never passes if the item property value is null.
        Parameters:
        valueProvider - a value provider that gets the string property value, not null
        locale - the locale to use for converting the strings to lower case, not null
        Returns:
        a data provider that filters accordingly, not null
      • filteringBySubstring

        default DataProvider<T,​String> filteringBySubstring​(ValueProvider<T,​String> valueProvider)
        Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of the filter value provided in the query is a substring of the lower case representation of an item property value. Conversion to lower case is done using the locale of the current UI if available, or otherwise the default locale. The filter never passes if the item property value is null.
        Parameters:
        valueProvider - a value provider that gets the string property value, not null
        Returns:
        a data provider that filters accordingly, not null
      • filteringByPrefix

        default DataProvider<T,​String> filteringByPrefix​(ValueProvider<T,​String> valueProvider,
                                                               Locale locale)
        Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of an item property value starts with the lower case representation of the filter value provided in the query. The filter never passes if the item property value is null.
        Parameters:
        valueProvider - a value provider that gets the string property value, not null
        locale - the locale to use for converting the strings to lower case, not null
        Returns:
        a data provider that filters accordingly, not null
      • filteringByPrefix

        default DataProvider<T,​String> filteringByPrefix​(ValueProvider<T,​String> valueProvider)
        Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of an item property value starts with the lower case representation of the filter value provided in the query. Conversion to lower case is done using the locale of the current UI if available, or otherwise the default locale. The filter never passes if the item property value is null.
        Parameters:
        valueProvider - a value provider that gets the string property value, not null
        Returns:
        a data provider that filters accordingly, not null