Package com.oorian.data
Class Query
java.lang.Object
com.oorian.data.Query
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 Summary
ConstructorsConstructorDescriptionQuery(int offset, int limit) Creates a query with pagination only.Query(int offset, int limit, List<SortDescriptor> sorts, List<FilterDescriptor> filters) Creates a query with pagination, sorting, and filtering. -
Method Summary
Modifier and TypeMethodDescriptionstatic Queryall()Creates a query that requests all items with no sorting or filtering.Returns the filter descriptors.intgetLimit()Returns the maximum number of items to return.intReturns the starting index.getSorts()Returns the sort descriptors.booleanReturns whether this query has any filter descriptors.booleanhasSorts()Returns whether this query has any sort descriptors.
-
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
Creates a query with pagination, sorting, and filtering.- Parameters:
offset- the starting index (0-based)limit- the maximum number of items to returnsorts- the sort descriptors (applied in order)filters- the filter descriptors (combined with AND logic)
-
-
Method Details
-
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
Returns the sort descriptors.- Returns:
- unmodifiable list of sort descriptors
-
getFilters
Returns the filter descriptors.- Returns:
- unmodifiable list of filter descriptors
-
hasSorts
public boolean hasSorts()Returns whether this query has any sort descriptors.- Returns:
trueif sorts are present
-
hasFilters
public boolean hasFilters()Returns whether this query has any filter descriptors.- Returns:
trueif filters are present
-