Skip to content

Commit

Permalink
Add lazy behavior in get()
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghaolu committed Mar 16, 2016
1 parent 6fc1dd9 commit 31794ef
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ public void clear() {

@Override
public E get(int index) {
while (index >= items.size() && nextPageLink != null) {
try {
Page<E> nextPage = loadPage(nextPageLink);
nextPageLink = nextPage.getNextPageLink();
addAll(nextPage.getItems());
} catch (CloudException e) {
throw new WebServiceException(e.toString(), e);
} catch (IOException e) {
throw new DataBindingException(e.getMessage(), e);
}
}
return items.get(index);
}

Expand Down

0 comments on commit 31794ef

Please sign in to comment.