Package sonia.scm.store
Interface QueryableStore.Query<T,T_RESULT>
- Type Parameters:
T
- The type of the objects to query.T_RESULT
- The type of the result objects (if a projection had been made, for example usingwithIds()
).
- Enclosing interface:
- QueryableStore<T>
public static interface QueryableStore.Query<T,T_RESULT>
The terminal interface for a query build by
QueryableStore.query(Condition[])
. It provides methods to retrieve the
result of the query in different forms.-
Method Summary
Modifier and TypeMethodDescription<A> Double
Returns the average value of the given field that match the query.long
count()
Returns the count of all objects that match the query.findAll()
Returns all objects that match the query.findAll
(long offset, long limit) Returns a subset of all objects that match the query.Returns the first found object, if the query returns at least one result.findOne()
Returns the found object, if the query returns one exactly one result.default void
Calls the given consumer for all objects that match the query.void
Calls the given consumer for a subset of all objects that match the query.<A> A
max
(QueryableStore.AggregatableQueryField<T, A> field) Returns the maximum value of the given field that match the query.<A> A
min
(QueryableStore.AggregatableQueryField<T, A> field) Returns the minimum value of the given field that match the query.orderBy
(QueryableStore.QueryField<T, ?> field, QueryableStore.Order order) Orders the result by the given field in the given order.<A> A
sum
(QueryableStore.AggregatableNumberQueryField<T, A> field) Returns the sum of the given field that match the query.withIds()
Returns the found objects in combination with the parent ids they belong to.
-
Method Details
-
findFirst
Returns the first found object, if the query returns at least one result. If the query returns no result, an empty optional will be returned. -
findOne
Returns the found object, if the query returns one exactly one result. When the query returns more than one result, aQueryableStore.TooManyResultsException
will be thrown. If the query returns no result, an empty optional will be returned. -
findAll
Returns all objects that match the query. If the query returns no result, an empty list will be returned. -
findAll
Returns a subset of all objects that match the query. If the query returns no result or theoffset
andlimit
are set in a way, that the result is exceeded, an empty list will be returned.- Parameters:
offset
- The offset to start the result list.limit
- The maximum number of results to return.
-
forEach
Calls the given consumer for all objects that match the query.- Parameters:
consumer
- The consumer that will be called for each single found object.
-
forEach
Calls the given consumer for a subset of all objects that match the query.- Parameters:
consumer
- The consumer that will be called for each single found object.offset
- The offset to start feeding results to the consumer.limit
- The maximum number of results.
-
withIds
QueryableStore.Query<T,QueryableStore.Result<T_RESULT>> withIds()Returns the found objects in combination with the parent ids they belong to. This is useful if you are using a queryable store that is not scoped to specific parent objects, and you therefore want to know to which parent objects each of the found objects belong to.- Returns:
- The query object to continue building the query.
-
orderBy
QueryableStore.Query<T,T_RESULT> orderBy(QueryableStore.QueryField<T, ?> field, QueryableStore.Order order) Orders the result by the given field in the given order. If the order is not set, the order of the result is not specified. Orders can be chained, so you can call this method multiple times to order by multiple fields.- Parameters:
field
- The field to order by.order
- The order to use (either ascending or descending).- Returns:
- The query object to continue building the query.
-
count
long count()Returns the count of all objects that match the query. -
min
Returns the minimum value of the given field that match the query. -
max
Returns the maximum value of the given field that match the query. -
sum
Returns the sum of the given field that match the query. -
average
Returns the average value of the given field that match the query.
-