Skip to content

Commit

Permalink
fixed page listing for no item lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
pomortaz committed Sep 2, 2016
1 parent e132607 commit a55439f
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public PagedList() {
*/
public PagedList(Page<E> page) {
this();
items.addAll(page.getItems());
List<E> retrievedItems = page.getItems();
if (retrievedItems != null && retrievedItems.size() != 0) {
items.addAll(retrievedItems);
}
nextPageLink = page.getNextPageLink();
currentPage = page;
}
Expand Down Expand Up @@ -138,14 +141,17 @@ public boolean hasNext() {
public E next() {
if (!itemsListItr.hasNext()) {
if (!hasNextPage()) {
throw new NoSuchElementException();
throw new NoSuchElementException();
} else {
int size = items.size();
loadNextPage();
itemsListItr = items.listIterator(size);
}
}
return itemsListItr.next();
if (itemsListItr.hasNext()) {
return itemsListItr.next();
}
return null;
}

@Override
Expand Down

0 comments on commit a55439f

Please sign in to comment.