com.holonplatform.core.query

## Interface QueryResults

- All Known Subinterfaces:
    Query

      public interface QueryResults

  Provide operations to get results from a `Query` execution.

  Query results are obtained through a projection using `QueryProjection`, allowing results type specification.

  Since:
    5.0.0
  See Also:
    `Query`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `QueryResults.QueryExecutionException` Exception thrown for `Query` execution errors.
    `static class` | `QueryResults.QueryNonUniqueResultException` Exception thrown by when only one query result was expected but more than one found.
    `static class` | `QueryResults.QueryResultConversionException` Exception thrown for `Query` results conversion or parsing errors.

  - ### 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 <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 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)
                        throws QueryResults.QueryExecutionException

      Execute query and get a `Stream` of query results using given `projection` to map results to required type.
      Type Parameters:
        `R` - Results type
      Parameters:
        `projection` - Query projection
      Returns:
        Query results stream
      Throws:
        `QueryResults.QueryExecutionException` - Error in query execution

    - #### list

          default <R> List<R> list(QueryProjection<R> projection)
                            throws QueryResults.QueryExecutionException

      Convenience method to obtain query results `stream(QueryProjection)` as a `List`
      Type Parameters:
        `R` - Results type
      Parameters:
        `projection` - Query projection
      Returns:
        Query results list
      Throws:
        `QueryResults.QueryExecutionException` - Error in query execution

    - #### findOne

          default <R> Optional<R> findOne(QueryProjection<R> projection)
                                   throws QueryResults.QueryExecutionException,
                                          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.

      Type Parameters:
        `R` - Result type
      Parameters:
        `projection` - Query projection
      Returns:
        Optional unique query result (an empty Optional if no results was returned from query execution)
      Throws:
        `QueryResults.QueryExecutionException` - Error in query execution
        `QueryResults.QueryNonUniqueResultException` - Only one result expected but more than one was found

    - #### count

          default long count()
                      throws QueryResults.QueryExecutionException

      Count all the results of a query.
      Returns:
        Total results count
      Throws:
        `QueryResults.QueryExecutionException` - Error in query execution

    - #### stream

          default <P extends Property> Stream<PropertyBox> stream(Iterable<P> properties)
                                                           throws QueryResults.QueryExecutionException

      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.

      Type Parameters:
        `P` - Property type
      Parameters:
        `properties` - Property set to fetch
      Returns:
        Query results `PropertyBox` stream
      Throws:
        `QueryResults.QueryExecutionException` - Error in query execution

    - #### findOne

          default <P extends Property> Optional<PropertyBox> findOne(Iterable<P> properties)
                                                              throws QueryResults.QueryExecutionException,
                                                                     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.

      Type Parameters:
        `P` - Property type
      Parameters:
        `properties` - Property set to fetch
      Returns:
        Optional unique query result (an empty Optional if no results was returned from query execution)
      Throws:
        `QueryResults.QueryExecutionException` - Error in query execution
        `QueryResults.QueryNonUniqueResultException` - Only one result expected but more than one was found

    - #### list

          default <P extends Property> List<PropertyBox> list(Iterable<P> properties)
                                                       throws QueryResults.QueryExecutionException

      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.

      Type Parameters:
        `P` - Property type
      Parameters:
        `properties` - Property set to fetch
      Returns:
        Query results `PropertyBox` list
      Throws:
        `QueryResults.QueryExecutionException` - Error in query execution

    - #### stream

          default Stream<PropertyBox> stream(Property... properties)
                                      throws QueryResults.QueryExecutionException

      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.

      Parameters:
        `properties` - Property set to fetch
      Returns:
        Query results `PropertyBox` stream
      Throws:
        `QueryResults.QueryExecutionException` - Error in query execution

    - #### findOne

          default Optional<PropertyBox> findOne(Property... properties)
                                         throws QueryResults.QueryExecutionException,
                                                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.

      Parameters:
        `properties` - Property set to fetch
      Returns:
        Optional unique query result (an empty Optional if no results was returned from query execution)
      Throws:
        `QueryResults.QueryExecutionException` - Error in query execution
        `QueryResults.QueryNonUniqueResultException` - Only one result expected but more than one was found

    - #### list

          default List<PropertyBox> list(Property... properties)
                                  throws QueryResults.QueryExecutionException

      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.

      Parameters:
        `properties` - Property set to fetch
      Returns:
        Query results `PropertyBox` list
      Throws:
        `QueryResults.QueryExecutionException` - Error in query execution

Copyright © 2017 The Holon Platform. All rights reserved.