Class Query<T,F>

java.lang.Object
com.vaadin.flow.data.provider.Query<T,F>
Type Parameters:
T - bean type
F - filter type
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
HierarchicalQuery

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.
Since:
1.0
See Also:
  • Constructor Details

    • 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 Details

    • 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 number 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
    • getPage

      public int getPage()
      Returns a zero-based page index to be retrieved.

      Vaadin asks data from the backend in paged manner. This shorthand calculates the page index for backends using paged data access, such as Spring Data repositories.

      Returns:
      the zero-based page index
    • getPageSize

      public int getPageSize()
      Returns the page size that should be returned. The amount of items can be smaller if there is no more items available in the backend.

      Vaadin asks data from the backend in paged manner.

      This is an alias for getLimit() if the page offset can be evenly divided by the limit. Else the page size will be increased to evenly divide offset so the items skip for page will go to the correct item.

      Returns:
      the page size used for data access
    • 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
    • getRequestedRangeEnd

      public int getRequestedRangeEnd()
      Gets the requested range end. This is a shorthand for getOffset() + getLimit() where the end is exclusive.
      Returns:
      the requested range end