GenericResponse (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.util, class: GenericResponse

# Class GenericResponse

java.lang.Object
org.apache.cayenne.util.GenericResponse

All Implemented Interfaces:
  `Serializable, QueryResponse`

public class GenericResponse extends Object implements QueryResponse, Serializable
A simple serializable implementation of QueryResponse.

Since:
  1.2
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected int`
  `currentIndex`
  `protected List<Object>`
  `results`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GenericResponse()`
  Creates an empty BaseResponse.
  `GenericResponse(List<?> list)`
  Creates a BaseResponse with a single result list.
  `GenericResponse(QueryResponse response)`
  Creates a response that it a shallow copy of another response.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addBatchUpdateCount(int[] resultCount)`
  `void`
  `addResultIterator(ResultIterator<?> iterator)`
  `void`
  `addResultList(List<?> list)`
  `void`
  `addUpdateCount(int resultCount)`
  `void`
  `clear()`
  Clears any previously collected information.
  `ResultIterator<?>`
  `currentIterator()`
  Returns a current iterator.
  `List<?>`
  `currentList()`
  Returns a List under the current iterator position.
  `int[]`
  `currentUpdateCount()`
  Returns an update count under the current iterator position.
  `ResultIterator<?>`
  `firstIterator()`
  A utility method for quickly retrieving the Iterator in the response.
  `List<?>`
  `firstList()`
  A utility method for quickly retrieving the first list in the response.
  `int[]`
  `firstUpdateCount()`
  A utility method for quickly retrieving the first update count from the response.
  `boolean`
  `isIterator()`
  Returns whether current response is an iterator
  `boolean`
  `isList()`
  Returns whether current iteration result is a list or an update count.
  `boolean`
  `next()`
  Rewinds response iterator to the next result, returning true if it is available.
  `void`
  `replaceResult(Object oldResult, Object newResult)`
  Replaces previously stored result with a new result.
  `void`
  `reset()`
  Restarts response iterator.
  `int`
  `size()`
  Returns a number of results in the response.

  ### Methods inherited from class Object

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

- ## Field Details

  - ### results

    protected List<Object> results

  - ### currentIndex

    protected transient int currentIndex

- ## Constructor Details

  - ### GenericResponse

    public GenericResponse()
    Creates an empty BaseResponse.

  - ### GenericResponse

    public GenericResponse(List<?> list)
    Creates a BaseResponse with a single result list.

  - ### GenericResponse

    public GenericResponse(QueryResponse response)
    Creates a response that it a shallow copy of another response.

- ## Method Details

  - ### firstList

    public List<?> firstList()
    Description copied from interface: `QueryResponse`
    A utility method for quickly retrieving the first list in the response. Returns null if the query has no lists. Note that this method resets current iterator to an undefined state.
    Specified by:
      `firstList` in interface `QueryResponse`

  - ### firstIterator

    public ResultIterator<?> firstIterator()
    Description copied from interface: `QueryResponse`
    A utility method for quickly retrieving the Iterator in the response. Returns null if the query has no iterator.
    Specified by:
      `firstIterator` in interface `QueryResponse`

  - ### firstUpdateCount

    public int[] firstUpdateCount()
    Description copied from interface: `QueryResponse`
    A utility method for quickly retrieving the first update count from the response. Note that this method resets current iterator to an undefined state.
    Specified by:
      `firstUpdateCount` in interface `QueryResponse`

  - ### currentList

    public List<?> currentList()
    Description copied from interface: `QueryResponse`
    Returns a List under the current iterator position. Use `QueryResponse.isList()` to check the result type before calling this method.
    Specified by:
      `currentList` in interface `QueryResponse`

  - ### currentIterator

    public ResultIterator<?> currentIterator()
    Description copied from interface: `QueryResponse`
    Returns a current iterator.
    Specified by:
      `currentIterator` in interface `QueryResponse`

  - ### currentUpdateCount

    public int[] currentUpdateCount()
    Description copied from interface: `QueryResponse`
    Returns an update count under the current iterator position. Returned value is an int[] to accommodate batch queries. For a regular update result, the value will be an int[1]. Use `QueryResponse.isList()` to check the result type before calling this method.
    Specified by:
      `currentUpdateCount` in interface `QueryResponse`

  - ### isList

    public boolean isList()
    Description copied from interface: `QueryResponse`
    Returns whether current iteration result is a list or an update count.
    Specified by:
      `isList` in interface `QueryResponse`

  - ### isIterator

    public boolean isIterator()
    Description copied from interface: `QueryResponse`
    Returns whether current response is an iterator
    Specified by:
      `isIterator` in interface `QueryResponse`

  - ### next

    public boolean next()
    Description copied from interface: `QueryResponse`
    Rewinds response iterator to the next result, returning true if it is available.
    Specified by:
      `next` in interface `QueryResponse`

  - ### reset

    public void reset()
    Description copied from interface: `QueryResponse`
    Restarts response iterator.
    Specified by:
      `reset` in interface `QueryResponse`

  - ### size

    public int size()
    Description copied from interface: `QueryResponse`
    Returns a number of results in the response.
    Specified by:
      `size` in interface `QueryResponse`

  - ### clear

    public void clear()
    Clears any previously collected information.

  - ### addBatchUpdateCount

    public void addBatchUpdateCount(int[] resultCount)

  - ### addUpdateCount

    public void addUpdateCount(int resultCount)

  - ### addResultList

    public void addResultList(List<?> list)

  - ### addResultIterator

    public void addResultIterator(ResultIterator<?> iterator)
    Parameters:
      `iterator` - to add as a result
    Since:
      5.0

  - ### replaceResult

    public void replaceResult(Object oldResult, Object newResult)
    Replaces previously stored result with a new result.