Package com.google.genai
Class AsyncPager
-
- All Implemented Interfaces:
public class AsyncPager<T extends JsonSerializable> extends BasePager<T>AsyncPager class for handling paginated results asynchronously.
-
-
Method Summary
Modifier and Type Method Description CompletableFuture<ImmutableList<T>>nextPage()Asynchronously fetches the next page of items. CompletableFuture<Void>forEach(Consumer<in T> itemAction)Asynchronously processes each item fetched by this pager. CompletableFuture<ImmutableList<T>>page()Asynchronously returns the current page of items as a list. CompletableFuture<String>name()Asynchronously returns the name of the item for this pager. CompletableFuture<Integer>pageSize()Asynchronously returns the page size for this pager. CompletableFuture<Integer>size()Asynchronously returns the size of the current page. CompletableFuture<Optional<HttpResponse>>sdkHttpResponse()Asynchronously returns an Optional of the HttpResponse for the current page, which can be used to get the http headers. -
-
Method Detail
-
nextPage
CompletableFuture<ImmutableList<T>> nextPage()
Asynchronously fetches the next page of items. This makes a new API request.
-
forEach
CompletableFuture<Void> forEach(Consumer<in 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
CompletableFuture<ImmutableList<T>> page()
Asynchronously returns the current page of items as a list.
-
name
CompletableFuture<String> name()
Asynchronously returns the name of the item for this pager.
-
pageSize
CompletableFuture<Integer> pageSize()
Asynchronously returns the page size for this pager.
-
size
CompletableFuture<Integer> size()
Asynchronously returns the size of the current page.
-
sdkHttpResponse
CompletableFuture<Optional<HttpResponse>> sdkHttpResponse()
Asynchronously returns an Optional of the HttpResponse for the current page, which can be used to get the http headers.
-
-
-
-