com.holonplatform.core.query

## Interface QueryResults

- All Superinterfaces:
    QueryProjectionOperations<Stream,List,Optional,Long>
  All Known Subinterfaces:
    LockQuery, Query

      public interface QueryResults
      extends QueryProjectionOperations<Stream,List,Optional,Long>

  Provide operations to get the results of a `Query` operation using a `QueryProjection`.
  Since:
    5.0.0
  See Also:
    `Query`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `QueryResults.QueryNonUniqueResultException` Exception thrown by when only one query result was expected but more than one found.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default long` | `count()` Count all the results of a query.
    `default Long` | `countAll()` Count all the results of a query.
    `default <P extends Property> Optional<PropertyBox>` | `findOne(Iterable<P> properties)` Execute query and get an expected unique result as `PropertyBox` using given `properties` as projection.
    `default Optional<PropertyBox>` | `findOne(Property... properties)` Execute query and get an expected unique result as `PropertyBox` using given `properties` as projection.
    `default <R> Optional<R>` | `findOne(QueryProjection<R> projection)` Execute query and get an expected unique result using `projection` to map result to required type.
    `default <P extends Property> List<PropertyBox>` | `list(Iterable<P> properties)` Execute query and get a `List` of query results as `PropertyBox` using given `properties` as projection.
    `default List<PropertyBox>` | `list(Property... properties)` Execute query and get a `List` of query results as `PropertyBox` using given `properties` as projection.
    `default <R> List<R>` | `list(QueryProjection<R> projection)` Convenience method to obtain the query results `stream(QueryProjection)` as a `List`
    `default <P extends Property> Stream<PropertyBox>` | `stream(Iterable<P> properties)` Execute query and get a `Stream` of query results as `PropertyBox` using given `properties` as projection.
    `default Stream<PropertyBox>` | `stream(Property... properties)` Execute query and get a `Stream` of query results as `PropertyBox` using given `properties` as projection.
    `<R> Stream<R>` | `stream(QueryProjection<R> projection)` Execute query and get a `Stream` of query results using given `projection` to map results to required type.

- - ### Method Detail

    - #### stream

          <R> Stream<R> stream(QueryProjection<R> projection)

      Execute query and get a `Stream` of query results using given `projection` to map results to required type.
      Specified by:
        `stream` in interface `QueryProjectionOperations<Stream,List,Optional,Long>`
      Type Parameters:
        `R` - Results type
      Parameters:
        `projection` - Query projection (not null)
      Returns:
        Query results stream, an empty Stream if none
      Throws:
        `DataAccessException` - Error in query execution

    - #### list

          default <R> List<R> list(QueryProjection<R> projection)

      Convenience method to obtain the query results `stream(QueryProjection)` as a `List`
      Specified by:
        `list` in interface `QueryProjectionOperations<Stream,List,Optional,Long>`
      Type Parameters:
        `R` - Results type
      Parameters:
        `projection` - Query projection (not null)
      Returns:
        Query results list, an empty List if none
      Throws:
        `DataAccessException` - Error in query execution

    - #### findOne

          default <R> Optional<R> findOne(QueryProjection<R> projection)
                                   throws QueryResults.QueryNonUniqueResultException

      Execute query and get an expected unique result using `projection` to map result to required type.

      If more than one result is returned by the query, a `QueryResults.QueryNonUniqueResultException` is thrown.

      Specified by:
        `findOne` in interface `QueryProjectionOperations<Stream,List,Optional,Long>`
      Type Parameters:
        `R` - Result type
      Parameters:
        `projection` - Query projection (not null)
      Returns:
        Optional unique query result (an empty Optional if no results was returned from query execution)
      Throws:
        `QueryResults.QueryNonUniqueResultException` - Only one result expected but more than one was found
        `DataAccessException` - Error in query execution

    - #### countAll

          default Long countAll()

      Count all the results of a query.
      Specified by:
        `countAll` in interface `QueryProjectionOperations<Stream,List,Optional,Long>`
      Returns:
        Total results count, an empty Optional if none
      Throws:
        `DataAccessException` - Error in query execution

    - #### count

          default long count()

      Count all the results of a query.

      This is `countAll()` alternative convenience method to provide a primitive long type result.

      Returns:
        Total results count
      Throws:
        `DataAccessException` - Error in query execution

    - #### stream

          default <P extends Property> Stream<PropertyBox> stream(Iterable<P> properties)

      Execute query and get a `Stream` of query results as `PropertyBox` using given `properties` as projection.

      Returned `PropertyBox` instances will contain the values of the properties specified in given `properties` set.

      Specified by:
        `stream` in interface `QueryProjectionOperations<Stream,List,Optional,Long>`
      Type Parameters:
        `P` - Property type
      Parameters:
        `properties` - Property set to use as projection (not null)
      Returns:
        Query results `PropertyBox` stream
      Throws:
        `DataAccessException` - Error in query execution

    - #### findOne

          default <P extends Property> Optional<PropertyBox> findOne(Iterable<P> properties)
                                                              throws QueryResults.QueryNonUniqueResultException

      Execute query and get an expected unique result as `PropertyBox` using given `properties` as projection.

      Returned `PropertyBox` instance will contain the values of the properties specified in given `properties` set.

      Specified by:
        `findOne` in interface `QueryProjectionOperations<Stream,List,Optional,Long>`
      Type Parameters:
        `P` - Property type
      Parameters:
        `properties` - Property set to use as projection (not null)
      Returns:
        Optional unique query result (an empty Optional if no results was returned from query execution)
      Throws:
        `QueryResults.QueryNonUniqueResultException` - Only one result expected but more than one was found
        `DataAccessException` - Error in query execution

    - #### list

          default <P extends Property> List<PropertyBox> list(Iterable<P> properties)

      Execute query and get a `List` of query results as `PropertyBox` using given `properties` as projection.

      Returned `PropertyBox` instances will contain the values of the properties specified in given `properties` set.

      Specified by:
        `list` in interface `QueryProjectionOperations<Stream,List,Optional,Long>`
      Type Parameters:
        `P` - Property type
      Parameters:
        `properties` - Property set to use as projection (not null)
      Returns:
        Query results `PropertyBox` list
      Throws:
        `DataAccessException` - Error in query execution

    - #### stream

          default Stream<PropertyBox> stream(Property... properties)

      Execute query and get a `Stream` of query results as `PropertyBox` using given `properties` as projection.

      Returned `PropertyBox` instances will contain the values of the properties specified in given `properties` set.

      Specified by:
        `stream` in interface `QueryProjectionOperations<Stream,List,Optional,Long>`
      Parameters:
        `properties` - Property set to use as projection (not null)
      Returns:
        Query results `PropertyBox` stream
      Throws:
        `DataAccessException` - Error in query execution

    - #### findOne

          default Optional<PropertyBox> findOne(Property... properties)
                                         throws QueryResults.QueryNonUniqueResultException

      Execute query and get an expected unique result as `PropertyBox` using given `properties` as projection.

      Returned `PropertyBox` instance will contain the values of the properties specified in given `properties` set.

      Specified by:
        `findOne` in interface `QueryProjectionOperations<Stream,List,Optional,Long>`
      Parameters:
        `properties` - Property set to use as projection (not null)
      Returns:
        Optional unique query result (an empty Optional if no results was returned from query execution)
      Throws:
        `QueryResults.QueryNonUniqueResultException` - Only one result expected but more than one was found
        `DataAccessException` - Error in query execution

    - #### list

          default List<PropertyBox> list(Property... properties)

      Execute query and get a `List` of query results as `PropertyBox` using given `properties` as projection.

      Returned `PropertyBox` instances will contain the values of the properties specified in given `properties` set.

      Specified by:
        `list` in interface `QueryProjectionOperations<Stream,List,Optional,Long>`
      Parameters:
        `properties` - Property set to use as projection (not null)
      Returns:
        Query results `PropertyBox` list
      Throws:
        `DataAccessException` - Error in query execution

Copyright © 2019 The Holon Platform. All rights reserved.