Package org.nuiton.util.pagination
Class PaginationParameter
java.lang.Object
org.nuiton.util.pagination.PaginationParameter
- All Implemented Interfaces:
java.io.Serializable
public class PaginationParameter
extends java.lang.Object
implements java.io.Serializable
This class represents the necessary information to do pagination (page number, size, ...).
- Since:
- 3.0
- Author:
- Arnaud Thimel (Code Lutin)
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPaginationParameter.PaginationParameterBuilderClass used to build an instance of PaginationParameter. -
Field Summary
Fields Modifier and Type Field Description static PaginationParameterALLAn instance that represents a page of ALL elementsprotected static intALL_PAGE_SIZEAll results.protected java.util.List<PaginationOrder>orderClausesThe list of order clauses.protected intpageNumber0-based page numberprotected intpageSizeThe size of each page. -
Constructor Summary
Constructors Modifier Constructor Description protectedPaginationParameter(int pageNumber, int pageSize)protectedPaginationParameter(int pageNumber, int pageSize, java.util.List<PaginationOrder> orderClauses) -
Method Summary
Modifier and Type Method Description static PaginationParameter.PaginationParameterBuilderbuilder(int pageNumber, int pageSize)Method to create a PaginationParameter using thePaginationParameter.PaginationParameterBuilder.booleanequals(java.lang.Object o)intgetEndIndex()Method that computes the end index of a page according topageNumberandpageSize.java.util.List<PaginationOrder>getOrderClauses()intgetPageNumber()intgetPageSize()intgetStartIndex()Method that computes the start index of a page according topageNumberandpageSize.inthashCode()booleanisAll()Test if pagination parameter is about all results range.static PaginationParameterof(int pageNumber, int pageSize)Method to create a PaginationParameter only based on pageNumber and pageSize (no order clauses).static PaginationParameterof(int pageNumber, int pageSize, java.lang.String orderClause1, boolean orderDesc1)Method to create a PaginationParameter based on pageNumber, pageSize and a single order clause.static PaginationParameterof(int pageNumber, int pageSize, java.lang.String orderClause1, boolean orderDesc1, java.lang.String orderClause2, boolean orderDesc2)Method to create a PaginationParameter based on pageNumber, pageSize and two order clauses.static PaginationParameterof(int pageNumber, int pageSize, java.lang.String orderClause1, boolean orderDesc1, java.lang.String orderClause2, boolean orderDesc2, java.lang.String orderClause3, boolean orderDesc3)Method to create a PaginationParameter based on pageNumber, pageSize and three order clauses.
-
Field Details
-
ALL_PAGE_SIZE
protected static final int ALL_PAGE_SIZEAll results.- See Also:
- Constant Field Values
-
ALL
An instance that represents a page of ALL elements -
pageNumber
protected int pageNumber0-based page number -
pageSize
protected int pageSizeThe size of each page. Value can be -1 (for infinite pageSize) or greater than 0 -
orderClauses
The list of order clauses. This instance is unmodifiable and never null.
-
-
Constructor Details
-
PaginationParameter
protected PaginationParameter(int pageNumber, int pageSize) -
PaginationParameter
protected PaginationParameter(int pageNumber, int pageSize, java.util.List<PaginationOrder> orderClauses)
-
-
Method Details
-
of
Method to create a PaginationParameter only based on pageNumber and pageSize (no order clauses).- Parameters:
pageNumber- the index (0-based) of the pagepageSize- the size of each page. Value can be -1 (for infinite pageSize) or greater than 0- Returns:
- an immutable PaginationParameter instance
-
of
public static PaginationParameter of(int pageNumber, int pageSize, java.lang.String orderClause1, boolean orderDesc1)Method to create a PaginationParameter based on pageNumber, pageSize and a single order clause. If you have an unknown number of order clauses, you should use thebuilder(int, int)method together withPaginationParameter.PaginationParameterBuilder.addOrder(String, boolean)andPaginationParameter.PaginationParameterBuilder.build()methods.- Parameters:
pageNumber- the index (0-based) of the pagepageSize- the size of each page. Value can be -1 (for infinite pageSize) or greater than 0orderClause1- an order clause attribute name. It comes together with {code}orderDesc1{/code}orderDesc1- the asc/desc property associated with {code}orderClause1{/code}- Returns:
- an immutable PaginationParameter instance
- See Also:
PaginationOrder,PaginationParameter.PaginationParameterBuilder
-
of
public static PaginationParameter of(int pageNumber, int pageSize, java.lang.String orderClause1, boolean orderDesc1, java.lang.String orderClause2, boolean orderDesc2)Method to create a PaginationParameter based on pageNumber, pageSize and two order clauses. If you have an unknown number of order clauses, you should use thebuilder(int, int)method together withPaginationParameter.PaginationParameterBuilder.addOrder(String, boolean)andPaginationParameter.PaginationParameterBuilder.build()methods.- Parameters:
pageNumber- the index (0-based) of the pagepageSize- the size of each page. Value can be -1 (for infinite pageSize) or greater than 0orderClause1- an order clause attribute name. It comes together with {code}orderDesc1{/code}orderDesc1- the asc/desc property associated with {code}orderClause1{/code}orderClause2- an order clause attribute name. It comes together with {code}orderDesc2{/code}orderDesc2- the asc/desc property associated with {code}orderClause2{/code}- Returns:
- an immutable PaginationParameter instance
- See Also:
PaginationOrder,PaginationParameter.PaginationParameterBuilder
-
of
public static PaginationParameter of(int pageNumber, int pageSize, java.lang.String orderClause1, boolean orderDesc1, java.lang.String orderClause2, boolean orderDesc2, java.lang.String orderClause3, boolean orderDesc3)Method to create a PaginationParameter based on pageNumber, pageSize and three order clauses. If you have more order clauses, or an unknown number of clauses, you should use thebuilder(int, int)method together withPaginationParameter.PaginationParameterBuilder.addOrder(String, boolean)andPaginationParameter.PaginationParameterBuilder.build()methods.- Parameters:
pageNumber- the index (0-based) of the pagepageSize- the size of each page. Value can be -1 (for infinite pageSize) or greater than 0orderClause1- an order clause attribute name. It comes together with {code}orderDesc1{/code}orderDesc1- the asc/desc property associated with {code}orderClause1{/code}orderClause2- an order clause attribute name. It comes together with {code}orderDesc2{/code}orderDesc2- the asc/desc property associated with {code}orderClause2{/code}orderClause3- an order clause attribute name. It comes together with {code}orderDesc3{/code}orderDesc3- the asc/desc property associated with {code}orderClause3{/code}- Returns:
- an immutable PaginationParameter instance
- See Also:
PaginationOrder,PaginationParameter.PaginationParameterBuilder
-
builder
Method to create a PaginationParameter using thePaginationParameter.PaginationParameterBuilder.- Parameters:
pageNumber- the index (0-based) of the pagepageSize- the size of each page. Value can be -1 (for infinite pageSize) or greater than 0- Returns:
- an immutable PaginationParameter.Builder instance
-
getPageNumber
public int getPageNumber() -
getPageSize
public int getPageSize() -
getOrderClauses
-
getStartIndex
public int getStartIndex()Method that computes the start index of a page according topageNumberandpageSize.- Returns:
- the computed start index
-
getEndIndex
public int getEndIndex()Method that computes the end index of a page according topageNumberandpageSize. If the pageSize is -1, the end index will beInteger.MAX_VALUE.- Returns:
- the computed end index
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
isAll
public boolean isAll()Test if pagination parameter is about all results range.- Returns:
trueif pagination parameter is about all results range
-