T
- the type of resource contained in this collectionpublic interface ResourceCollection<T> extends Iterable<T>
Modifier and Type | Method and Description |
---|---|
ResourcePage<T> |
firstPage()
Makes exactly one service call to retrieve the first page of
results from this collection.
|
ResourcePage<T> |
firstPage(ResultCapture<Object> extractor)
Makes exactly one service call to retrieve the first page of
results from this collection.
|
Iterator<T> |
iterator()
Returns an
Iterator which will lazily paginate through the
entire collection, potentially making multiple service calls as the
iterator is used. |
Iterable<ResourcePage<T>> |
pages()
Returns a view of this collection as a set of pages rather
than a set of resources.
|
Iterator<T> iterator()
Iterator
which will lazily paginate through the
entire collection, potentially making multiple service calls as the
iterator is used.
This method will not block or throw an exception, but calls to
hasNext
and next
on the returned Iterator
may.
The code:
for (T resource : collection) { handle(resource); }Is precisely equivalent to:
for (ResourcePagepage : collection.pages()) { for (T resource : page) { handle(resource); } }
Iterable<ResourcePage<T>> pages()
Iterator.next()
will make exactly one call to the service
and return the full page of results.
for (ResourcePage> page : collection.pages()) { System.out.println("Got " + page.size() + " results."); }
Iterable
collection of resource pagesResourcePage<T> firstPage()
ResourcePage.nextPage()
on the returned value.ResourcePage<T> firstPage(ResultCapture<Object> extractor)
ResourcePage.nextPage()
on the returned value. Also
extracts the request id and raw client-level result object for
examination.extractor
- a result extractor objectCopyright © 2014. All rights reserved.