Class Paginator<T>

java.lang.Object
codes.grow.packages.awssecretsmanager.Paginator<T>
Type Parameters:
T - item type
All Implemented Interfaces:
Iterable<T>

public final class Paginator<T> extends Object implements Iterable<T>
Lazily walks every page of an AWS list operation (ListSecrets, ListSecretVersionIds). Iterate with a for-each loop, use stream(), or collect everything with toList(). Each iteration starts again from the first page; a page is fetched only when the previous one is consumed.
  • Constructor Details

    • Paginator

      public Paginator(Function<String,Paginator.Page<T>> fetch)
      Creates a paginator.
      Parameters:
      fetch - fetches one page for a token (null for the first page)
  • Method Details

    • pages

      public Iterable<List<T>> pages()
      Returns the pages (one list per page).
      Returns:
      a lazy iterable of pages
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • stream

      public Stream<T> stream()
      Returns a sequential stream of every item.
      Returns:
      the stream
    • toList

      public List<T> toList()
      Collects every item of every page.
      Returns:
      the items