Class PagedIterable<T>

java.lang.Object
com.okta.sdk.resource.client.PagedIterable<T>
Type Parameters:
T - The type of item in the collection (e.g., User)
All Implemented Interfaces:
Iterable<T>

public class PagedIterable<T> extends Object implements Iterable<T>
A new lazy, paginated iterable. This class is a "recipe" for fetching paginated data. It does no work until the iterator() method is called (e.g., by a for-each loop). Each call to iterator() creates a new, independent PagedIterator instance, ensuring thread-safety and isolation of pagination state.
  • Constructor Details

    • PagedIterable

      public PagedIterable(Function<String,ApiResponse<List<T>>> pageFetcher)
      Constructs a new PagedIterable with the given page fetching strategy.
      Parameters:
      pageFetcher - A function that takes a next URL (or null for the first page) and returns an ApiResponse containing a list of items and headers.
  • Method Details

    • iterator

      public Iterator<T> iterator()
      Creates a new, stateful iterator. This is the key to thread-safety: every loop gets its own private iterator to manage its own private state.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      A new PagedIterator instance for this iteration.