Package alpine.util

Class 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
    • Constructor Detail

      • Pageable

        public Pageable​(int pageSize,
                        List<T> list)
        Creates a new Pageable instance.
        Parameters:
        pageSize - the page size to use
        list - the list to paginate through
    • 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.