DATACMNS-323 - PageImpl returns correct number of pages for use with content only.

So far, the PageImpl class returned 0 as total number of pages if set up from a plain List. This returns 1 now (as it should be). We've also adapted the hasNextPage() implementation to correctly calculate whether a next page is available.
This commit is contained in:
Oliver Gierke
2013-05-14 16:40:45 +02:00
parent 602834f86a
commit 70ce9a0908
2 changed files with 16 additions and 3 deletions

View File

@@ -84,7 +84,7 @@ public class PageImpl<T> implements Page<T>, Serializable {
* @see org.springframework.data.domain.Page#getTotalPages()
*/
public int getTotalPages() {
return getSize() == 0 ? 0 : (int) Math.ceil((double) total / (double) getSize());
return getSize() == 0 ? 1 : (int) Math.ceil((double) total / (double) getSize());
}
/*
@@ -124,7 +124,7 @@ public class PageImpl<T> implements Page<T>, Serializable {
* @see org.springframework.data.domain.Page#hasNextPage()
*/
public boolean hasNextPage() {
return (getNumber() + 1) * getSize() < total;
return getNumber() + 1 < getTotalPages();
}
/*