Class Paginator<T>

java.lang.Object
com.aquima.web.rest.v1.paginator.Paginator<T>
Type Parameters:
T - the resource type this paginator can handle
All Implemented Interfaces:
IPaginator<T>
Direct Known Subclasses:
FilteringPaginator, NonFilteringPaginator

public abstract class Paginator<T> extends Object implements IPaginator<T>
Base class for paginators.
Author:
Radu Batori
  • Constructor Details Link icon

    • Paginator Link icon

      public Paginator(List<T> list, Integer pageNumber, Integer pageSize, Integer itemCount)
      Parameters:
      list - the resources to paginate (may be all resources or a page of resources)
      pageNumber - the current page number (may be null - null disables pagination)
      pageSize - the page size (may be null - disables pagination)
      itemCount - the total item count (not necessarily equal to list size)
  • Method Details Link icon

    • getPageSize Link icon

      public Integer getPageSize()
      Specified by:
      getPageSize in interface IPaginator<T>
      Returns:
      the page size (number of resources per page)
    • getPageNumber Link icon

      public Integer getPageNumber()
      Specified by:
      getPageNumber in interface IPaginator<T>
      Returns:
      the index current page number
    • getFirstPage Link icon

      public Integer getFirstPage()
      Specified by:
      getFirstPage in interface IPaginator<T>
      Returns:
      the index of the first page
    • getLastPage Link icon

      public Integer getLastPage()
      Specified by:
      getLastPage in interface IPaginator<T>
      Returns:
      the index of the last page
    • getPrevPage Link icon

      public Integer getPrevPage()
      Description copied from interface: IPaginator
      Returns the index of the previous page. If the current page is also the first page, the index of the previous page equals the index of the first page.
      Specified by:
      getPrevPage in interface IPaginator<T>
      Returns:
      the index of the previous page.
    • getNextPage Link icon

      public Integer getNextPage()
      Description copied from interface: IPaginator
      Returns the index of the next page. If the current page is also the last page, the index of the next page equals the index of the last page.
      Specified by:
      getNextPage in interface IPaginator<T>
      Returns:
      the index of the next page
    • getNumberOfItems Link icon

      public Integer getNumberOfItems()
      Specified by:
      getNumberOfItems in interface IPaginator<T>
      Returns:
      the total number of items (prior to pagination).
    • getNumberOfPages Link icon

      public Integer getNumberOfPages()
      Specified by:
      getNumberOfPages in interface IPaginator<T>
      Returns:
      the total number of pages (after pagination).
    • hasPrevPage Link icon

      public boolean hasPrevPage()
      Specified by:
      hasPrevPage in interface IPaginator<T>
      Returns:
      true if there is a previous page.
    • hasNextPage Link icon

      public boolean hasNextPage()
      Specified by:
      hasNextPage in interface IPaginator<T>
      Returns:
      true if there is a next page.
    • paginate Link icon

      protected void paginate(PagedObject<T> pagedObject)
      If paging is enabled, sets page-related properties of the given paged object.
      Parameters:
      pagedObject - the resource where the paginated resources are placed
    • getList Link icon

      protected List<T> getList()