Package com.microsoft.graph.core.tasks
Class PageIterator<TEntity extends com.microsoft.kiota.serialization.Parsable,TCollectionPage extends com.microsoft.kiota.serialization.Parsable & com.microsoft.kiota.serialization.AdditionalDataHolder>
java.lang.Object
com.microsoft.graph.core.tasks.PageIterator<TEntity,TCollectionPage>
- Type Parameters:
TEntity- The type of the entity returned in the collection. This type must implementParsableTCollectionPage- The Microsoft Graph collection response type returned in the collection response. This type must implementParsableandAdditionalDataHolder
public class PageIterator<TEntity extends com.microsoft.kiota.serialization.Parsable,TCollectionPage extends com.microsoft.kiota.serialization.Parsable & com.microsoft.kiota.serialization.AdditionalDataHolder>
extends Object
A class for iterating through pages of a collection
Use to automatically page through result sets across multiple calls and process each item in the result set.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPageIterator.Builder<TEntity extends com.microsoft.kiota.serialization.Parsable,TCollectionPage extends com.microsoft.kiota.serialization.Parsable & com.microsoft.kiota.serialization.AdditionalDataHolder> A builder class for building a PageIterator.static enumEnum to represent the possible states of the PageIterator. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new instance of the PageIterator class -
Method Summary
Modifier and TypeMethodDescriptionprotected static <TEntity extends com.microsoft.kiota.serialization.Parsable,TCollectionPage extends com.microsoft.kiota.serialization.Parsable & com.microsoft.kiota.serialization.AdditionalDataHolder>
List<TEntity> extractEntityListFromParsable(TCollectionPage parsableCollection) Extracts the list of entities from the Parsable collection page.The deltaLink returned from a delta query.The nextLink returned from a collection query.The state of the page iteratorvoiditerate()Iterates over the collection of entities in the collation page.voidresume()Resumes the iteration over the collection of entities in the collation page.protected voidsetCollectionPageFactory(com.microsoft.kiota.serialization.ParsableFactory<TCollectionPage> collectionPageFactory) The factory to use for creating the collection page instance.protected voidsetCurrentPage(TCollectionPage currentPage) The current page of the collection.protected voidsetPageItemQueue(Queue<TEntity> pageItemQueue) The queue of items in the current page.protected voidsetProcessPageItemCallback(Function<TEntity, Boolean> processPageItemCallback) The processPageItemCallback to use for processing each item in the collection.protected voidsetRequestAdapter(com.microsoft.kiota.RequestAdapter requestAdapter) Sets the request adapter to use for requests in the page iterator.protected voidsetRequestConfigurator(UnaryOperator<com.microsoft.kiota.RequestInformation> requestConfigurator) The request configurator to use for requests in the page iterator.
-
Constructor Details
-
PageIterator
protected PageIterator()Creates a new instance of the PageIterator class
-
-
Method Details
-
getDeltaLink
The deltaLink returned from a delta query.- Returns:
- the deltaLink from the delta query
-
getNextLink
The nextLink returned from a collection query.- Returns:
- the nextLink from the collection query
-
getPageIteratorState
The state of the page iterator- Returns:
- the state of the page iterator
-
setRequestAdapter
protected void setRequestAdapter(@Nonnull com.microsoft.kiota.RequestAdapter requestAdapter) Sets the request adapter to use for requests in the page iterator.- Parameters:
requestAdapter- the request adapter to use for requests.
-
setCollectionPageFactory
protected void setCollectionPageFactory(@Nonnull com.microsoft.kiota.serialization.ParsableFactory<TCollectionPage> collectionPageFactory) The factory to use for creating the collection page instance.- Parameters:
collectionPageFactory- the factory to use for creating the collection page.
-
setRequestConfigurator
protected void setRequestConfigurator(@Nullable UnaryOperator<com.microsoft.kiota.RequestInformation> requestConfigurator) The request configurator to use for requests in the page iterator.- Parameters:
requestConfigurator- the request configurator to use when modifying requests.
-
setCurrentPage
The current page of the collection.- Parameters:
currentPage- the current page of the collection.
-
setProcessPageItemCallback
protected void setProcessPageItemCallback(@Nonnull Function<TEntity, Boolean> processPageItemCallback) The processPageItemCallback to use for processing each item in the collection.- Parameters:
processPageItemCallback- the processPageItemCallback to use for processing each item in the collection.
-
setPageItemQueue
The queue of items in the current page.- Parameters:
pageItemQueue- the queue of items in the current page.
-
iterate
Iterates over the collection of entities in the collation page. Will continues to iterate over the collection of entities in the next page, if there is a next page.- Throws:
com.microsoft.kiota.ApiException- if the request was unable to complete for any reason.ReflectiveOperationException- if the entity or collection page could not be instantiated or if they are of invalid types.
-
resume
Resumes the iteration over the collection of entities in the collation page.- Throws:
com.microsoft.kiota.ApiException- if the request was unable to complete for any reason.ReflectiveOperationException- if the entity or collection page could not be instantiated or if they are of invalid types.
-
extractEntityListFromParsable
@Nonnull protected static <TEntity extends com.microsoft.kiota.serialization.Parsable,TCollectionPage extends com.microsoft.kiota.serialization.Parsable & com.microsoft.kiota.serialization.AdditionalDataHolder> List<TEntity> extractEntityListFromParsable(@Nonnull TCollectionPage parsableCollection) throws IllegalAccessException, InvocationTargetException Extracts the list of entities from the Parsable collection page.- Type Parameters:
TEntity- the type of the entity.TCollectionPage- the type of the collection page.- Parameters:
parsableCollection- the Parsable collection page.- Returns:
- the list of entities.
- Throws:
IllegalAccessException- if the Parsable does not contain a collection property.InvocationTargetException- if the Parsable does not contain a collection property.
-