T - The type of the list elementspublic class Pagination<T> extends Object implements Iterable<T>
getItems() retrieves all items on the current page.
A pagination object can be used as an Iterable. When the
Iterator from iterator() is requested, the iterator over
getItems() is returned.
| Constructor and Description |
|---|
Pagination(List<T> list,
int pageSize)
Paginates the given list.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getItemCount()
Returns the number of items on the current page.
|
List<T> |
getItems()
Returns the items on the current page.
|
int |
getLastPage()
Returns the index of the last page.
|
int |
getNextPage()
Returns the index of the next page.
|
int |
getPage()
Returns the current page, 0-based.
|
int |
getPageCount()
Returns the total number of pages.
|
int |
getPageNumber()
Returns the current page, 1-based.
|
int |
getPageSize()
Returns the number of items per page.
|
int |
getPreviousPage()
Returns the index of the previous page.
|
boolean |
isFirst()
Returns whether the current page is the first page
|
boolean |
isLast()
Returns whether the current page is the last page.
|
boolean |
isNecessary()
Returns whether pagination is actually necessary, i.e. if the number of
pages is greater than 1.
|
Iterator<T> |
iterator() |
Pagination<T> |
setPage(int page)
Sets the new page.
|
Pagination<T> |
setPageSize(int pageSize)
Sets the page size.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic int getPage()
public int getPageNumber()
public Pagination<T> setPage(int page)
page - The new page numberpublic int getPageCount()
public int getPageSize()
public Pagination<T> setPageSize(int pageSize)
pageSize - The new page sizepublic int getItemCount()
public List<T> getItems()
public boolean isFirst()
true if the current page is the first page, false
otherwisepublic boolean isLast()
true if the current page is the last page, false
otherwisepublic boolean isNecessary()
true if there are more than one page in this pagination,
false otherwisepublic int getPreviousPage()
isFirst() should be
called first to determine whether there is a page before the current
page.public int getNextPage()
isLast() should be called
first to determine whether there is a page after the current page.public int getLastPage()
Copyright © 2026. All rights reserved.