Class PaginationResult<T extends BaseEntity>

  • Direct Known Subclasses:
    CacheablePaginationResult

    public class PaginationResult<T extends BaseEntity>
    extends java.lang.Object
    Class for a simple pagination implementation.
    Author:
    Collin Alpert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<Query<T>> queries  
    • Constructor Summary

      Constructors 
      Constructor Description
      PaginationResult​(java.util.List<Query<T>> queries)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getNumberOfPages()
      Gets the amount of pages created to split up a query.
      java.util.List<T> getPage​(int number)
      Retrieves a specific page represented by a List.
      java.util.stream.Stream<T> getPageAsStream​(int number)
      Retrieves a specific page represented by a Stream.
      PaginationResult<T> orderBy​(com.github.collinalpert.lambda2sql.functions.SqlFunction<T,​?> orderFunction)
      An overload of the orderBy(SqlFunction, OrderTypes) method.
      PaginationResult<T> orderBy​(com.github.collinalpert.lambda2sql.functions.SqlFunction<T,​?> orderFunction, OrderTypes orderType)
      Adds an ORDER BY statement to the queries executed for the pages.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • PaginationResult

        public PaginationResult​(java.util.List<Query<T>> queries)
    • Method Detail

      • getNumberOfPages

        public int getNumberOfPages()
        Gets the amount of pages created to split up a query.
        Returns:
        The number of pages created for the result.
      • getPage

        public java.util.List<T> getPage​(int number)
        Retrieves a specific page represented by a List. Only then will a query to the database be executed.
        Parameters:
        number - The number of the page. The first page has the index 1.
        Returns:
        A List of entities on this page.
      • getPageAsStream

        public java.util.stream.Stream<T> getPageAsStream​(int number)
        Retrieves a specific page represented by a Stream. Only then will a query to the database be executed.
        Parameters:
        number - The number of the page. The first page has the index 1.
        Returns:
        A Stream of entities on this page.
      • orderBy

        public PaginationResult<T> orderBy​(com.github.collinalpert.lambda2sql.functions.SqlFunction<T,​?> orderFunction,
                                           OrderTypes orderType)
        Adds an ORDER BY statement to the queries executed for the pages. Note that this will order the entire pagination structure and not every page separately.
        Parameters:
        orderFunction - The function to order by.
        orderType - The direction of order.
        Returns:
        This object with the added ordering feature.