org.apache.cayenne.util

## Class GenericQueryResult<T>

- java.lang.Object
- - org.apache.cayenne.util.GenericQueryResult<T>

- All Implemented Interfaces:
    Iterable<QueryResultItem>, QueryResult<T>
  Direct Known Subclasses:
    ProcedureResult

      public class GenericQueryResult<T>
      extends Object
      implements QueryResult<T>

  Generic implementation of QueryResult using List as QueryResultItem storage.
  Since:
    4.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Class<T>` | `resultClass`
    `protected List<QueryResultItem>` | `resultItems`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GenericQueryResult(List<QueryResultItem> resultItems)`
    `GenericQueryResult(List<QueryResultItem> resultItems, Class<T> resultClass)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int[]` | `firstBatchUpdateCount()` A utility method for quickly retrieving the first batch update count array from the response.
    `List<T>` | `firstList()` A utility method for quickly retrieving the first list in the response.
    `int` | `firstUpdateCount()` A utility method for quick retrieval of the first update count from the response.
    `boolean` | `isList()` Returns whether current iteration result is a list or an update count.
    `Iterator<QueryResultItem>` | `iterator()`
    `int` | `size()` Returns a number of results in the response.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Field Detail

    - #### resultClass

          protected Class<T> resultClass

    - #### resultItems

          protected List<QueryResultItem> resultItems

  - ### Constructor Detail

    - #### GenericQueryResult

          public GenericQueryResult(List<QueryResultItem> resultItems)

    - #### GenericQueryResult

          public GenericQueryResult(List<QueryResultItem> resultItems,
                                    Class<T> resultClass)

  - ### Method Detail

    - #### size

          public int size()

      Description copied from interface: `QueryResult`
      Returns a number of results in the response.
      Specified by:
        `size` in interface `QueryResult<T>`

    - #### isList

          public boolean isList()

      Description copied from interface: `QueryResult`
      Returns whether current iteration result is a list or an update count.
      Specified by:
        `isList` in interface `QueryResult<T>`

    - #### firstList

          public List<T> firstList()

      Description copied from interface: `QueryResult`
      A utility method for quickly retrieving the first list in the response. Returns null if the query has no lists.
      Specified by:
        `firstList` in interface `QueryResult<T>`

    - #### firstBatchUpdateCount

          public int[] firstBatchUpdateCount()

      Description copied from interface: `QueryResult`
      A utility method for quickly retrieving the first batch update count array from the response.
      Specified by:
        `firstBatchUpdateCount` in interface `QueryResult<T>`

    - #### firstUpdateCount

          public int firstUpdateCount()

      Description copied from interface: `QueryResult`
      A utility method for quick retrieval of the first update count from the response.
      Specified by:
        `firstUpdateCount` in interface `QueryResult<T>`

    - #### iterator

          public Iterator<QueryResultItem> iterator()

      Specified by:
        `iterator` in interface `Iterable<QueryResultItem>`

Copyright © 2001–2023 Apache Cayenne. All rights reserved.