Class PagingScanner<K,T>

java.lang.Object
io.datarouter.scanner.BaseScanner<List<T>>
io.datarouter.scanner.PagingScanner<K,T>
All Implemented Interfaces:
Scanner<List<T>>, Closeable, AutoCloseable

public abstract class PagingScanner<K,T> extends BaseScanner<List<T>>
Base class for things that page through results by passing the last item as an exclusive start key for the next page
  • Field Details

    • pageSize

      protected final int pageSize
  • Constructor Details

    • PagingScanner

      protected PagingScanner(int pageSize)
  • Method Details

    • nextParam

      protected abstract Optional<K> nextParam(T lastSeenItem)
      Subclass should transform the last seen item into a key for the next request
    • nextPage

      protected abstract List<T> nextPage(Optional<K> resumeFrom)
    • advance

      public boolean advance()
      Description copied from interface: Scanner
      Try to update current to the next item, if there is one.
      Returns:
      True if it advanced