Module bus.pager

Class Paginating<T>

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

public class Paginating<T> extends Serialize<T>
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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default number of navigation pages.

    Fields inherited from class org.miaixz.bus.pager.Serialize

    list, total
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default 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 Type
    Method
    Description
    void
    calcByNavigatePages(int navigatePages)
    Calculates pagination properties based on the number of navigation pages.
    <E> Paginating<E>
    convert(org.miaixz.bus.core.center.function.FunctionX<T,E> function)
    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.
    long
    Retrieves the row number of the last element in the current page.
    int
    Retrieves the first page number in the navigation bar.
    int
    Retrieves the last page number in the navigation bar.
    int[]
    Retrieves the array of navigation page numbers.
    int
    Retrieves the number of navigation pages to display.
    int
    Retrieves the page number of the next page.
    int
    Retrieves the current page number.
    int
    Retrieves the total number of pages.
    int
    Retrieves the number of records per page.
    int
    Retrieves the page number of the previous page.
    int
    Retrieves the number of records in the current page.
    long
    Retrieves the row number of the first element in the current page.
    boolean
    Checks if the paginating object contains any data.
    boolean
    Checks if there is a next page.
    boolean
    Checks if there is a previous page.
    boolean
    Checks if the current page is the first page.
    boolean
    Checks if the current page is the last page.
    static <T> Paginating<T>
    of(long total, List<? extends T> list)
    Static factory method to create a Paginating object with a specified total number of records.
    static <T> Paginating<T>
    of(List<? extends T> list)
    Static factory method to create a Paginating object.
    static <T> Paginating<T>
    of(List<? extends T> list, int navigatePages)
    Static factory method to create a Paginating object with a specified number of navigation pages.
    void
    setEndRow(long endRow)
    Sets the row number of the last element in the current page.
    void
    setHasNextPage(boolean hasNextPage)
    Sets whether there is a next page.
    void
    setHasPreviousPage(boolean hasPreviousPage)
    Sets whether there is a previous page.
    void
    setIsFirstPage(boolean isFirstPage)
    Sets whether the current page is the first page.
    void
    setIsLastPage(boolean isLastPage)
    Sets whether the current page is the last page.
    void
    setNavigateFirstPage(int navigateFirstPage)
    Sets the first page number in the navigation bar.
    void
    setNavigateLastPage(int navigateLastPage)
    Sets the last page number in the navigation bar.
    void
    setNavigatepageNo(int[] navigatepageNo)
    Sets the array of navigation page numbers.
    void
    setNavigatePages(int navigatePages)
    Sets the number of navigation pages to display.
    void
    setNextPage(int nextPage)
    Sets the page number of the next page.
    void
    setPageNo(int pageNo)
    Sets the current page number.
    void
    setPages(int pages)
    Sets the total number of pages.
    void
    setPageSize(int pageSize)
    Sets the number of records per page.
    void
    setPrePage(int prePage)
    Sets the page number of the previous page.
    void
    setSize(int size)
    Sets the number of records in the current page.
    void
    setStartRow(long startRow)
    Sets the row number of the first element in the current page.
    Returns a string representation of the Paginating object.

    Methods inherited from class org.miaixz.bus.pager.Serialize

    getList, getTotal, setList, setTotal

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_NAVIGATE_PAGES

      public static final int DEFAULT_NAVIGATE_PAGES
      Default number of navigation pages.
      See Also:
  • Constructor Details

    • Paginating

      public Paginating()
      Default constructor for Paginating.
    • Paginating

      public Paginating(List<? extends T> list)
      Constructs a Paginating object by wrapping a list of paginated results. Uses DEFAULT_NAVIGATE_PAGES for navigation.
      Parameters:
      list - the list of paginated results
    • Paginating

      public 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.
      Parameters:
      list - the list of paginated results
      navigatePages - the number of navigation pages to display
  • Method Details

    • of

      public static <T> Paginating<T> of(List<? extends T> list)
      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

      public static <T> Paginating<T> of(long total, List<? extends T> list)
      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 records
      list - the list of paginated results
      Returns:
      a new Paginating object
    • of

      public static <T> Paginating<T> of(List<? extends T> list, int navigatePages)
      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 results
      navigatePages - the number of navigation pages to display
      Returns:
      a new Paginating object
    • emptyPageInfo

      public static <T> Paginating<T> 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
    • calcByNavigatePages

      public void calcByNavigatePages(int navigatePages)
      Calculates pagination properties based on the number of navigation pages.
      Parameters:
      navigatePages - the number of navigation pages to display
    • convert

      public <E> Paginating<E> convert(org.miaixz.bus.core.center.function.FunctionX<T,E> function)
      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
    • getNavigatePages

      public int getNavigatePages()
      Retrieves the number of navigation pages to display.
      Returns:
      the number of navigation pages
    • setNavigatePages

      public void setNavigatePages(int navigatePages)
      Sets the number of navigation pages to display.
      Parameters:
      navigatePages - the number of navigation pages to set
    • getNavigatepageNo

      public int[] getNavigatepageNo()
      Retrieves the array of navigation page numbers.
      Returns:
      an array of navigation page numbers
    • setNavigatepageNo

      public void setNavigatepageNo(int[] navigatepageNo)
      Sets the array of navigation page numbers.
      Parameters:
      navigatepageNo - the array of navigation page numbers to set
    • getNavigateFirstPage

      public int getNavigateFirstPage()
      Retrieves the first page number in the navigation bar.
      Returns:
      the first navigation page number
    • setNavigateFirstPage

      public void setNavigateFirstPage(int navigateFirstPage)
      Sets the first page number in the navigation bar.
      Parameters:
      navigateFirstPage - the first navigation page number to set
    • getNavigateLastPage

      public int getNavigateLastPage()
      Retrieves the last page number in the navigation bar.
      Returns:
      the last navigation page number
    • setNavigateLastPage

      public void setNavigateLastPage(int navigateLastPage)
      Sets the last page number in the navigation bar.
      Parameters:
      navigateLastPage - the last navigation page number to set
    • toString

      public String toString()
      Returns a string representation of the Paginating object.
      Overrides:
      toString in class Serialize<T>
      Returns:
      a string representation of the object