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 using withIds()).
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 Details

    • findFirst

      Optional<T_RESULT> 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, a QueryableStore.TooManyResultsException will be thrown. If the query returns no result, an empty optional will be returned.
      Throws:
      QueryableStore.TooManyResultsException
    • findAll

      default List<T_RESULT> findAll()
      Returns all objects that match the query. If the query returns no result, an empty list will be returned.
    • findAll

      List<T_RESULT> findAll(long offset, long limit)
      Returns a subset of all objects that match the query. If the query returns no result or the offset and limit 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

      default void forEach(Consumer<T_RESULT> consumer)
      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

      void forEach(Consumer<T_RESULT> consumer, long offset, long limit)
      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

      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

      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.