Class 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.

     FluentIterable 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.

        Optional 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
      PagedIterable()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.common.collect.FluentIterable<E> concat()
      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
    • Constructor Detail

      • PagedIterable

        public PagedIterable()
    • Method Detail

      • 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>)