java.lang.Object
org.miaixz.bus.pager.Serialize<T>
org.miaixz.bus.pager.Paginating<T>
- Type Parameters:
T- the type of elements in the paginated data
- All Implemented Interfaces:
Serializable
Wraps the
Page result, adding pagination-related properties to support navigation and page information
display.- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault number of navigation pages. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for Paginating.Paginating(List<? extends T> list) Constructs a Paginating object by wrapping a list of paginated results.Paginating(List<? extends T> list, int navigatePages) Constructs a Paginating object by wrapping a list of paginated results and specifying the number of navigation pages. -
Method Summary
Modifier and TypeMethodDescriptionvoidcalcByNavigatePages(int navigatePages) Calculates pagination properties based on the number of navigation pages.<E> Paginating<E> Converts the paginated data to a different type using a provided function.static <T> Paginating<T> Static factory method to return an empty Paginating object.longRetrieves the row number of the last element in the current page.intRetrieves the first page number in the navigation bar.intRetrieves the last page number in the navigation bar.int[]Retrieves the array of navigation page numbers.intRetrieves the number of navigation pages to display.intRetrieves the page number of the next page.intRetrieves the current page number.intgetPages()Retrieves the total number of pages.intRetrieves the number of records per page.intRetrieves the page number of the previous page.intgetSize()Retrieves the number of records in the current page.longRetrieves the row number of the first element in the current page.booleanChecks if the paginating object contains any data.booleanChecks if there is a next page.booleanChecks if there is a previous page.booleanChecks if the current page is the first page.booleanChecks if the current page is the last page.static <T> Paginating<T> Static factory method to create a Paginating object with a specified total number of records.static <T> Paginating<T> Static factory method to create a Paginating object.static <T> Paginating<T> Static factory method to create a Paginating object with a specified number of navigation pages.voidsetEndRow(long endRow) Sets the row number of the last element in the current page.voidsetHasNextPage(boolean hasNextPage) Sets whether there is a next page.voidsetHasPreviousPage(boolean hasPreviousPage) Sets whether there is a previous page.voidsetIsFirstPage(boolean isFirstPage) Sets whether the current page is the first page.voidsetIsLastPage(boolean isLastPage) Sets whether the current page is the last page.voidsetNavigateFirstPage(int navigateFirstPage) Sets the first page number in the navigation bar.voidsetNavigateLastPage(int navigateLastPage) Sets the last page number in the navigation bar.voidsetNavigatepageNo(int[] navigatepageNo) Sets the array of navigation page numbers.voidsetNavigatePages(int navigatePages) Sets the number of navigation pages to display.voidsetNextPage(int nextPage) Sets the page number of the next page.voidsetPageNo(int pageNo) Sets the current page number.voidsetPages(int pages) Sets the total number of pages.voidsetPageSize(int pageSize) Sets the number of records per page.voidsetPrePage(int prePage) Sets the page number of the previous page.voidsetSize(int size) Sets the number of records in the current page.voidsetStartRow(long startRow) Sets the row number of the first element in the current page.toString()Returns a string representation of the Paginating object.
-
Field Details
-
DEFAULT_NAVIGATE_PAGES
public static final int DEFAULT_NAVIGATE_PAGESDefault number of navigation pages.- See Also:
-
-
Constructor Details
-
Paginating
public Paginating()Default constructor for Paginating. -
Paginating
Constructs a Paginating object by wrapping a list of paginated results. UsesDEFAULT_NAVIGATE_PAGESfor navigation.- Parameters:
list- the list of paginated results
-
Paginating
Constructs a Paginating object by wrapping a list of paginated results and specifying the number of navigation pages.- Parameters:
list- the list of paginated resultsnavigatePages- the number of navigation pages to display
-
-
Method Details
-
of
Static factory method to create a Paginating object.- Type Parameters:
T- the type of elements in the paginated data- Parameters:
list- the list of paginated results- Returns:
- a new Paginating object
-
of
Static factory method to create a Paginating object with a specified total number of records.- Type Parameters:
T- the type of elements in the paginated data- Parameters:
total- the total number of recordslist- the list of paginated results- Returns:
- a new Paginating object
-
of
Static factory method to create a Paginating object with a specified number of navigation pages.- Type Parameters:
T- the type of elements in the paginated data- Parameters:
list- the list of paginated resultsnavigatePages- the number of navigation pages to display- Returns:
- a new Paginating object
-
emptyPageInfo
Static factory method to return an empty Paginating object.- Type Parameters:
T- the type of elements in the paginated data- Returns:
- an empty Paginating object
-
convert
Converts the paginated data to a different type using a provided function.- Type Parameters:
E- the target data type- Parameters:
function- the data conversion function- Returns:
- a new Paginating object with converted data
-
hasContent
public boolean hasContent()Checks if the paginating object contains any data.- Returns:
- true if it contains data, false otherwise
-
getPageNo
public int getPageNo()Retrieves the current page number.- Returns:
- the current page number
-
setPageNo
public void setPageNo(int pageNo) Sets the current page number.- Parameters:
pageNo- the current page number to set
-
getPageSize
public int getPageSize()Retrieves the number of records per page.- Returns:
- the number of records per page
-
setPageSize
public void setPageSize(int pageSize) Sets the number of records per page.- Parameters:
pageSize- the number of records per page to set
-
getSize
public int getSize()Retrieves the number of records in the current page.- Returns:
- the number of records in the current page
-
setSize
public void setSize(int size) Sets the number of records in the current page.- Parameters:
size- the number of records in the current page to set
-
getStartRow
public long getStartRow()Retrieves the row number of the first element in the current page.- Returns:
- the row number of the first element
-
setStartRow
public void setStartRow(long startRow) Sets the row number of the first element in the current page.- Parameters:
startRow- the row number of the first element to set
-
getEndRow
public long getEndRow()Retrieves the row number of the last element in the current page.- Returns:
- the row number of the last element
-
setEndRow
public void setEndRow(long endRow) Sets the row number of the last element in the current page.- Parameters:
endRow- the row number of the last element to set
-
getPages
public int getPages()Retrieves the total number of pages.- Returns:
- the total number of pages
-
setPages
public void setPages(int pages) Sets the total number of pages.- Parameters:
pages- the total number of pages to set
-
getPrePage
public int getPrePage()Retrieves the page number of the previous page.- Returns:
- the previous page number
-
setPrePage
public void setPrePage(int prePage) Sets the page number of the previous page.- Parameters:
prePage- the previous page number to set
-
getNextPage
public int getNextPage()Retrieves the page number of the next page.- Returns:
- the next page number
-
setNextPage
public void setNextPage(int nextPage) Sets the page number of the next page.- Parameters:
nextPage- the next page number to set
-
isIsFirstPage
public boolean isIsFirstPage()Checks if the current page is the first page.- Returns:
- true if it is the first page, false otherwise
-
setIsFirstPage
public void setIsFirstPage(boolean isFirstPage) Sets whether the current page is the first page.- Parameters:
isFirstPage- true if it is the first page, false otherwise
-
isIsLastPage
public boolean isIsLastPage()Checks if the current page is the last page.- Returns:
- true if it is the last page, false otherwise
-
setIsLastPage
public void setIsLastPage(boolean isLastPage) Sets whether the current page is the last page.- Parameters:
isLastPage- true if it is the last page, false otherwise
-
isHasPreviousPage
public boolean isHasPreviousPage()Checks if there is a previous page.- Returns:
- true if there is a previous page, false otherwise
-
setHasPreviousPage
public void setHasPreviousPage(boolean hasPreviousPage) Sets whether there is a previous page.- Parameters:
hasPreviousPage- true if there is a previous page, false otherwise
-
isHasNextPage
public boolean isHasNextPage()Checks if there is a next page.- Returns:
- true if there is a next page, false otherwise
-
setHasNextPage
public void setHasNextPage(boolean hasNextPage) Sets whether there is a next page.- Parameters:
hasNextPage- true if there is a next page, false otherwise
-
toString
Returns a string representation of the Paginating object.
-