Package alpine.common.util
Class Pageable<T>
java.lang.Object
alpine.common.util.Pageable<T>
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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the current page number.getList()Returns the list as specified in the constructor.intReturns the page size as specified in the constructor.Returns a sublist (paginated) of the original list based on the current page number.intReturns the total number of pages.booleanDetermines if there are more pages.booleanDetermines if a loop should break out of pagination.voidnextPage()Advances the pagination to the next page.
-
Constructor Details
-
Pageable
Creates a new Pageable instance.- Parameters:
pageSize- the page size to uselist- the list to paginate through
-
-
Method Details
-
getPageSize
public int getPageSize()Returns the page size as specified in the constructor.- Returns:
- the page size
-
getList
Returns the list as specified in the constructor.- Returns:
- the original list to paginate through
-
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.
-