mirror of https://github.com/apache/jclouds.git
Merge pull request #1387 from rackspace/pagediterable-javadoc
Updated Javadoc for PagedIterable.
This commit is contained in:
commit
46f9219272
|
@ -27,31 +27,33 @@ import com.google.common.collect.UnmodifiableIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends {@link FluentIterable} allowing you to lazily advance through
|
* Extends {@link FluentIterable} allowing you to lazily advance through
|
||||||
* sequence of pages in a resultset. Typically used in apis that return only a
|
* sequence of pages in a result set. Typically used in APIs that return only a
|
||||||
* certain number of records at a time.
|
* certain number of records at a time.
|
||||||
*
|
* </p>
|
||||||
* Simplest usage is to employ the {@link #concat} convenience function, and one
|
* Simplest usage is to employ the {@link #concat} convenience function, and iterate.
|
||||||
* of the methods from {@link FluentIterable}.
|
* </p>
|
||||||
*
|
|
||||||
* <pre>
|
* <pre>
|
||||||
* // pull in new pages until it we see something interesting.
|
* FluentIterable<? extends Image> images = imageApi.listInDetail().concat();
|
||||||
* Optional<StorageMetadata> firstInterestingBlob = blobstore
|
*
|
||||||
* .list(// options //)
|
* for (Image image: images) {
|
||||||
* .concat()
|
* System.out.println(image);
|
||||||
* .firstMatch(isInterestingBlob());
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
* </p>
|
||||||
* For those seeking manual control of page advances, don't use concat, and
|
* Another usage is to employ the {@link #concat} convenience function, and one
|
||||||
* instead look at the value of {@link IterableWithMarker#nextToken}.
|
* of the methods from {@link FluentIterable}.
|
||||||
*
|
* </p>
|
||||||
* <pre>
|
* <pre>
|
||||||
* PagedIterator<StorageMetadata> blobs = blobstore.list(...).iterator();
|
* Optional<? extends Image> image = imageApi.listInDetail().concat().firstMatch(isInterestingImage());
|
||||||
* while (blobs.hasNext()) {
|
* System.out.println(image.orNull());
|
||||||
* IterableWithMarker<StorageMetadata> page = blobs.next();
|
* ...
|
||||||
* ProcessedResults results = process(page);
|
* private static Predicate<Image> isInterestingImage() {
|
||||||
* if (results.shouldBeBookmarked() && page.nextMarker().isPresent()) {
|
* return new Predicate<Image>() {
|
||||||
* saveBookmark(page.nextMarker().get());
|
* {@literal @}Override
|
||||||
* }
|
* public boolean apply(Image image) {
|
||||||
|
* return image.getName().startsWith("Arch");
|
||||||
|
* }
|
||||||
|
* };
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue