Last active
December 12, 2023 15:04
-
-
Save maisarissi/c83eb0c87006790e6524d019e0b92c28 to your computer and use it in GitHub Desktop.
microsoftgraph-java-v6-pagination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the messages | |
MessageCollectionResponse messages = graphClient.me().messages().get(); | |
// Instantiate collection to store all messgaes | |
List<Message> messagesList = new LinkedList<Message>(); | |
// Configure iterator | |
PageIterator iterator = new PageIterator.Builder<Message, MessageCollectionResponse>() | |
.client(graphClient) | |
.collectionPage(messages) | |
// Type of response expected for each page | |
.collectionPageFactory(MessageCollectionResponse::createFromDiscriminatorValue) | |
// Callback on how to handle each message encountered | |
.processPageItemCallback(message -> { | |
messagesList.add(message); | |
return true; }) | |
.build(); | |
iterator.iterate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment