Class PaginationResult<T extends BaseEntity>
- java.lang.Object
-
- com.github.collinalpert.java2db.pagination.PaginationResult<T>
-
- Direct Known Subclasses:
CacheablePaginationResult
public class PaginationResult<T extends BaseEntity> extends java.lang.ObjectClass for a simple pagination implementation.- Author:
- Collin Alpert
-
-
Constructor Summary
Constructors Constructor Description PaginationResult(java.util.List<Query<T>> queries)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intgetNumberOfPages()Gets the amount of pages created to split up a query.java.util.List<T>getPage(int number)Retrieves a specific page represented by aList.java.util.stream.Stream<T>getPageAsStream(int number)Retrieves a specific page represented by aStream.PaginationResult<T>orderBy(OrderTypes orderType, com.github.collinalpert.lambda2sql.functions.SqlFunction<T,?>... orderFunctions)Adds ORDER BY statements to the queries executed for the pages in a coalescing manner.PaginationResult<T>orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<T,?> orderFunction)Deprecated, for removal: This API element is subject to removal in a future version.Since the coalescing feature for ORDER BY statements was introduced, there is no need for the single-parameter methods.PaginationResult<T>orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<T,?>... orderFunctions)Adds ascending ORDER BY statements to the queries executed for the pages in a coalescing manner.PaginationResult<T>orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<T,?> orderFunction, OrderTypes orderType)Deprecated, for removal: This API element is subject to removal in a future version.Since the coalescing feature for ORDER BY statements was introduced, there is no need for the single-parameter methods.
-
-
-
Field Detail
-
queries
protected final java.util.List<Query<T extends BaseEntity>> 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 aList. 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
Listof entities on this page.
-
getPageAsStream
public java.util.stream.Stream<T> getPageAsStream(int number)
Retrieves a specific page represented by aStream. 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
Streamof entities on this page.
-
orderBy
@Deprecated(since="3.1.2", forRemoval=true) public PaginationResult<T> orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<T,?> orderFunction)Deprecated, for removal: This API element is subject to removal in a future version.Since the coalescing feature for ORDER BY statements was introduced, there is no need for the single-parameter methods. As removing them would be a breaking change, these methods will be removed as part of release 4.0.An overload of theorderBy(OrderTypes, SqlFunction...)method. Will order in an ascending fashion.- Parameters:
orderFunction- The function to order by.- Returns:
- This object with the added ordering feature.
- See Also:
orderBy(OrderTypes, SqlFunction...)
-
orderBy
@Deprecated(since="3.1.2", forRemoval=true) public PaginationResult<T> orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<T,?> orderFunction, OrderTypes orderType)Deprecated, for removal: This API element is subject to removal in a future version.Since the coalescing feature for ORDER BY statements was introduced, there is no need for the single-parameter methods. As removing them would be a breaking change, these methods will be removed as part of release 4.0.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.
-
orderBy
@SafeVarargs public final PaginationResult<T> orderBy(com.github.collinalpert.lambda2sql.functions.SqlFunction<T,?>... orderFunctions)
Adds ascending ORDER BY statements to the queries executed for the pages in a coalescing manner. Note that this will order the entire pagination structure and not every page separately.- Parameters:
orderFunctions- The columns to order by.- Returns:
- The object with an ORDER BY statement
-
orderBy
@SafeVarargs public final PaginationResult<T> orderBy(OrderTypes orderType, com.github.collinalpert.lambda2sql.functions.SqlFunction<T,?>... orderFunctions)
Adds ORDER BY statements to the queries executed for the pages in a coalescing manner. Note that this will order the entire pagination structure and not every page separately.- Parameters:
orderType- The direction of order.orderFunctions- The columns to order by.- Returns:
- The object with an ORDER BY statement
-
-