Class EagerPaginator<Resp,​T>

  • All Implemented Interfaces:
    java.util.Iterator<T>
    Direct Known Subclasses:
    ListScheduleListDescriptionIterator

    public abstract class EagerPaginator<Resp,​T>
    extends java.lang.Object
    implements java.util.Iterator<T>
    The main goal for this Iterator implementation is to abstract the functionality of "eager pagination". This implementation requests the next page when we start iterating through the previous page. The main goal of this approach is to reduce a synchronous wait that would otherwise happen when a first element of the next page is requested.
    • Constructor Summary

      Constructors 
      Constructor Description
      EagerPaginator()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract com.google.protobuf.ByteString getNextPageToken​(Resp response)  
      boolean hasNext()  
      void init()  
      T next()  
      protected abstract java.util.concurrent.CompletableFuture<Resp> performRequest​(com.google.protobuf.ByteString nextPageToken)  
      protected abstract java.util.List<T> toElements​(Resp response)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, remove
    • Constructor Detail

      • EagerPaginator

        public EagerPaginator()
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<Resp>
      • next

        public T next()
        Specified by:
        next in interface java.util.Iterator<Resp>
      • init

        public void init()
      • performRequest

        protected abstract java.util.concurrent.CompletableFuture<Resp> performRequest​(@Nonnull
                                                                                       com.google.protobuf.ByteString nextPageToken)
      • getNextPageToken

        protected abstract com.google.protobuf.ByteString getNextPageToken​(Resp response)
      • toElements

        protected abstract java.util.List<T> toElements​(Resp response)