Skip to content

Instantly share code, notes, and snippets.

@codingtim
Last active February 18, 2017 10:29
Show Gist options
  • Save codingtim/1e24c419eefffa7d1b4a171b27627bf5 to your computer and use it in GitHub Desktop.
Save codingtim/1e24c419eefffa7d1b4a171b27627bf5 to your computer and use it in GitHub Desktop.
public class PagedDataSourceConsumer {
private PagedDataSource pagedDataSource;
public void consume() {
List<Entity> entities;
Paging nextPage = Paging.firstPage();
for(entities = pagedDataSource.getEntities(nextPage); !entities.isEmpty(); entities = pagedDataSource.getEntities(nextPage)) {
for(Entity entity: entities) {
//doStuff
}
nextPage = nextPage.next();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment