Class Query

java.lang.Object
com.oorian.data.Query

public class Query extends Object
Encapsulates fetch parameters for a DataProvider query.

Contains pagination (offset/limit), sort descriptors, and filter descriptors. Instances are immutable once created.


 // Fetch first 25 items, sorted by name ascending
 Query query = new Query(0, 25,
     List.of(SortDescriptor.asc("name")),
     Collections.emptyList());

 // Fetch all items
 Query all = Query.all();
 
Since:
2.1
Version:
1.0
Author:
Marvin P. Warble Jr.
  • Constructor Details

    • Query

      public Query(int offset, int limit)
      Creates a query with pagination only.
      Parameters:
      offset - the starting index (0-based)
      limit - the maximum number of items to return
    • Query

      public Query(int offset, int limit, List<SortDescriptor> sorts, List<FilterDescriptor> filters)
      Creates a query with pagination, sorting, and filtering.
      Parameters:
      offset - the starting index (0-based)
      limit - the maximum number of items to return
      sorts - the sort descriptors (applied in order)
      filters - the filter descriptors (combined with AND logic)
  • Method Details

    • all

      public static Query all()
      Creates a query that requests all items with no sorting or filtering.
      Returns:
      a query with offset 0 and limit Integer.MAX_VALUE
    • getOffset

      public int getOffset()
      Returns the starting index.
      Returns:
      the offset (0-based)
    • getLimit

      public int getLimit()
      Returns the maximum number of items to return.
      Returns:
      the limit
    • getSorts

      public List<SortDescriptor> getSorts()
      Returns the sort descriptors.
      Returns:
      unmodifiable list of sort descriptors
    • getFilters

      public List<FilterDescriptor> getFilters()
      Returns the filter descriptors.
      Returns:
      unmodifiable list of filter descriptors
    • hasSorts

      public boolean hasSorts()
      Returns whether this query has any sort descriptors.
      Returns:
      true if sorts are present
    • hasFilters

      public boolean hasFilters()
      Returns whether this query has any filter descriptors.
      Returns:
      true if filters are present