com.vaadin.flow.data.provider.

Class Query<T,F>

  • Type Parameters:

    T - bean type

    F - filter type

    All Implemented Interfaces:

    Serializable


    public class Query<T,F>
    extends Object
    implements Serializable

    Immutable query object used to request data from a backend. Contains index limits, sorting and filtering information.

    See Also:

    Serialized Form

    • Constructor Detail

      • Query

        public Query()

        Constructs a Query for all rows from 0 to Integer.MAX_VALUE without sorting and filtering.

      • Query

        public Query(F filter)

        Constructs a Query for all rows from 0 to Integer.MAX_VALUE with filtering.

        Parameters:

        filter - back end filter of a suitable type for the data provider; can be null

      • Query

        public Query(int offset,
                     int limit,
                     List<QuerySortOrder> sortOrders,
                     Comparator<T> inMemorySorting,
                     F filter)

        Constructs a new Query object with given offset, limit, sorting and filtering.

        Parameters:

        offset - first index to fetch

        limit - fetched item count

        sortOrders - sorting order for fetching; used for sorting backends

        inMemorySorting - comparator for sorting in-memory data

        filter - filtering for fetching; can be null

    • Method Detail

      • getOffset

        public int getOffset()

        Gets the first index of items to fetch. The offset is only used when fetching items, but not when counting the number of available items.

        Returns:

        offset for data request

      • getLimit

        public int getLimit()

        Gets the limit of items to fetch. The limit is only used when fetching items, but not when counting the number of available items.

        Note: It is possible that offset + limit > item count

        Returns:

        number of items to fetch

      • getSortOrders

        public List<QuerySortOrder> getSortOrders()

        Gets the sorting for items to fetch. This list of sort orders is used for sorting backends. The sort orders are only used when fetching items, but not when counting the number of available items.

        Note: Sort orders and in-memory sorting are mutually exclusive. If the DataProvider handles one, it should ignore the other.

        Returns:

        list of sort orders

      • getFilter

        public Optional<F> getFilter()

        Gets the filter for items to fetch.

        Returns:

        optional filter

      • getInMemorySorting

        public Comparator<T> getInMemorySorting()

        Gets the comparator for sorting in-memory data. The comparator is only used when fetching items, but not when counting the number of available items.

        Note: Sort orders and in-memory sorting are mutually exclusive. If the DataProvider handles one, it should ignore the other.

        Returns:

        sorting comparator

      • getSortingComparator

        public Optional<Comparator<T>> getSortingComparator()

        Gets the optional comparator for sorting data. The comparator is only used when fetching items, but not when counting the number of available items.

        Note: Sort orders and comparator sorting are mutually exclusive. If the DataProvider handles one, it should ignore the other.

        Returns:

        optional sorting comparator