Package alpine.util
Class Pageable<T>
- java.lang.Object
-
- alpine.util.Pageable<T>
-
public class Pageable<T> extends Object
This class provides a simple way to paginate through a List without having to implement a new type.- Since:
- 1.3.0
- Author:
- Steve Springett
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCurrentPage()Returns the current page number.List<T>getList()Returns the list as specified in the constructor.intgetPageSize()Returns the page size as specified in the constructor.List<T>getPaginatedList()Returns a sublist (paginated) of the original list based on the current page number.intgetTotalPages()Returns the total number of pages.booleanhasMorePages()Determines if there are more pages.booleanisPaginationComplete()Determines if a loop should break out of pagination.voidnextPage()Advances the pagination to the next page.
-
-
-
Method Detail
-
getPageSize
public int getPageSize()
Returns the page size as specified in the constructor.- Returns:
- the page size
-
getList
public List<T> getList()
Returns the list as specified in the constructor.- Returns:
- the original list to paginate through
-
getPaginatedList
public List<T> getPaginatedList()
Returns a sublist (paginated) of the original list based on the current page number.- Returns:
- a paginated list
-
getCurrentPage
public int getCurrentPage()
Returns the current page number.- Returns:
- the current page number
-
getTotalPages
public int getTotalPages()
Returns the total number of pages.- Returns:
- the total number of pages
-
hasMorePages
public boolean hasMorePages()
Determines if there are more pages.- Returns:
- true if more pages exist, false if not
-
isPaginationComplete
public boolean isPaginationComplete()
Determines if a loop should break out of pagination.- Returns:
- true if more pages exist, false if not
-
nextPage
public void nextPage()
Advances the pagination to the next page.
-
-