Class PagedIterable<E>

java.lang.Object
com.google.common.collect.FluentIterable<IterableWithMarker<E>>
org.jclouds.collect.PagedIterable<E>
All Implemented Interfaces:
Iterable<IterableWithMarker<E>>

@Beta public abstract class PagedIterable<E> extends com.google.common.collect.FluentIterable<IterableWithMarker<E>>
Extends FluentIterable allowing you to lazily advance through sequence of pages in a result set. Typically used in APIs that return only a certain number of records at a time.

Simplest usage is to employ the concat() convenience function, and iterate.

 FluentIterableinvalid input: '<'? extends Image> images = imageApi.listInDetail().concat();

 for (Image image: images) {
    System.out.println(image);
 }
 

Another usage is to employ the concat() convenience function, and one of the methods from FluentIterable.

    Optionalinvalid input: '<'? extends Image> image = imageApi.listInDetail().concat().firstMatch(isInterestingImage());
    System.out.println(image.orNull());
 ...
 private static Predicate isInterestingImage() {
    return new Predicate() {
       @Override
       public boolean apply(Image image) {
          return image.getName().startsWith("Arch");
       }
    };
 }
 
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.common.collect.FluentIterable<E>
    Combines all the pages into a single unmodifiable iterable.

    Methods inherited from class com.google.common.collect.FluentIterable

    allMatch, anyMatch, append, append, concat, concat, concat, concat, concat, contains, copyInto, cycle, filter, filter, first, firstMatch, from, from, from, get, index, isEmpty, join, last, limit, of, of, size, skip, stream, toArray, toList, toMap, toMultiset, toSet, toSortedList, toSortedSet, toString, transform, transformAndConcat, uniqueIndex

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Constructor Details

    • PagedIterable

      public PagedIterable()
  • Method Details

    • concat

      public com.google.common.collect.FluentIterable<E> concat()
      Combines all the pages into a single unmodifiable iterable. ex.
       FluentIterable blobs = blobstore.list(...).concat();
       for (StorageMetadata blob : blobs) {
           process(blob);
       }
       
      See Also:
      • Iterators.concat(java.util.Iterator<? extends T>, java.util.Iterator<? extends T>)