Package com.google.genai
Class AsyncPager<T extends JsonSerializable>
java.lang.Object
com.google.genai.AsyncPager<T>
AsyncPager class for handling paginated results asynchronously.
-
Method Summary
Modifier and TypeMethodDescriptionAsynchronously processes each item fetched by this pager.name()
Asynchronously returns the name of the item for this pager.CompletableFuture<com.google.common.collect.ImmutableList<T>>
nextPage()
Asynchronously fetches the next page of items.CompletableFuture<com.google.common.collect.ImmutableList<T>>
page()
Asynchronously returns the current page of items as a list.pageSize()
Asynchronously returns the page size for this pager.Asynchronously returns an Optional of theHttpResponse
for the current page, which can be used to get the http headers.size()
Asynchronously returns the size of the current page.
-
Method Details
-
nextPage
Asynchronously fetches the next page of items. This makes a new API request. -
forEach
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
Asynchronously returns the current page of items as a list. -
name
Asynchronously returns the name of the item for this pager. -
pageSize
Asynchronously returns the page size for this pager. -
size
Asynchronously returns the size of the current page. -
sdkHttpResponse
Asynchronously returns an Optional of theHttpResponse
for the current page, which can be used to get the http headers.
-