Class PaginationParameter
java.lang.Object
org.nuiton.util.pagination.PaginationParameter
- All Implemented Interfaces:
Serializable
This class represents the necessary information to do pagination (page number, size, ...).
- Since:
- 3.0
- Author:
- Arnaud Thimel (Code Lutin)
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass used to build an instance of PaginationParameter. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PaginationParameterAn instance that represents a page of ALL elementsprotected static final intAll results.protected List<PaginationOrder> The list of order clauses.protected int0-based page numberprotected intThe size of each page. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPaginationParameter(int pageNumber, int pageSize) protectedPaginationParameter(int pageNumber, int pageSize, List<PaginationOrder> orderClauses) -
Method Summary
Modifier and TypeMethodDescriptionbuilder(int pageNumber, int pageSize) Method to create a PaginationParameter using thePaginationParameter.PaginationParameterBuilder.booleanintMethod that computes the end index of a page according topageNumberandpageSize.intintintMethod 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 PaginationParameterMethod to create a PaginationParameter based on pageNumber, pageSize and a single order clause.static PaginationParameterof(int pageNumber, int pageSize, String orderClause1, boolean orderDesc1, String orderClause2, boolean orderDesc2) Method to create a PaginationParameter based on pageNumber, pageSize and two order clauses.static PaginationParameterof(int pageNumber, int pageSize, String orderClause1, boolean orderDesc1, String orderClause2, boolean orderDesc2, 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:
-
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
-
-
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, 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:
-
of
public static PaginationParameter of(int pageNumber, int pageSize, String orderClause1, boolean orderDesc1, 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:
-
of
public static PaginationParameter of(int pageNumber, int pageSize, String orderClause1, boolean orderDesc1, String orderClause2, boolean orderDesc2, 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:
-
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
-
hashCode
-
isAll
public boolean isAll()Test if pagination parameter is about all results range.- Returns:
trueif pagination parameter is about all results range
-