Class AsyncPager<T extends JsonSerializable>

java.lang.Object
com.google.genai.AsyncPager<T>

public class AsyncPager<T extends JsonSerializable> extends Object
AsyncPager class for handling paginated results asynchronously.
  • Method Details

    • nextPage

      public CompletableFuture<com.google.common.collect.ImmutableList<T>> nextPage()
      Asynchronously fetches the next page of items. This makes a new API request.
    • forEach

      public CompletableFuture<Void> forEach(Consumer<? super T> itemAction)
      Asynchronously processes each item fetched by this pager. The provided consumer action will be applied to each item sequentially across all pages.
      Parameters:
      itemAction - The action to perform on each item.
    • page

      public CompletableFuture<com.google.common.collect.ImmutableList<T>> page()
      Asynchronously returns the current page of items as a list.
    • name

      public CompletableFuture<String> name()
      Asynchronously returns the name of the item for this pager.
    • pageSize

      public CompletableFuture<Integer> pageSize()
      Asynchronously returns the page size for this pager.
    • size

      public CompletableFuture<Integer> size()
      Asynchronously returns the size of the current page.