Class ResponseRecordIterator<REQUESTBUILDER,​REQUEST,​RESPONSE,​ITEMTYPE>

  • Type Parameters:
    REQUESTBUILDER - the type of a builder which can produce requests for a list operation
    REQUEST - the type of a request to a list operation. This type must match the type produced by REQUESTBUILDER
    RESPONSE - the type of the response from a list operation
    ITEMTYPE - the type of the model/resource returned inside the response
    All Implemented Interfaces:
    Iterator<ITEMTYPE>

    public class ResponseRecordIterator<REQUESTBUILDER,​REQUEST,​RESPONSE,​ITEMTYPE>
    extends AbstractResponseIterator<REQUESTBUILDER,​REQUEST,​RESPONSE>
    implements Iterator<ITEMTYPE>
    An iterator for iterating over response objects returned from a list operation.

    This iterator handles calling the service for additional data when needed. However, not every advancement of the iterator (via its next() method) will result in a method call. Instead, the logic of this iterator can be described as:

    1. Fetch a page of results from the service
    2. next() will vend individual model/resource objects from that page until there are no more to vend
    3. Call the service for the next page of results
    4. Repeat steps 2 and 3 until there are no more results
        This iterator does not support removal of elements.
    • Constructor Detail

      • ResponseRecordIterator

        public ResponseRecordIterator​(REQUESTBUILDER requestBuilder,
                                      Function<RESPONSE,​String> nextPageTokenRetrievalFunction,
                                      Function<RequestBuilderAndToken<REQUESTBUILDER>,​REQUEST> requestBuilderFunction,
                                      Function<REQUEST,​RESPONSE> pageRetrievalFunction,
                                      Function<RESPONSE,​List<ITEMTYPE>> retrieveItemsFromResponseFunction)
        Constructs a new ResponseRecordIterator.
        Parameters:
        requestBuilder - a builder object which can create requests for a list operation
        nextPageTokenRetrievalFunction - a function which can extract the next page token from a response produced by a list operation
        requestBuilderFunction - a function which can build a request for a list operation based on a builder object and a pagination token to use
        pageRetrievalFunction - a function which will call a list operation with a request and return the response of the call
        retrieveItemsFromResponseFunction - a function which can extract the collection of results from a response produced by a list operation