Class PageRequest
- java.lang.Object
-
- de.digitalcollections.model.paging.PageRequest
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SearchPageRequest
public class PageRequest extends Object implements Serializable
Basic Java Bean implementation ofPageRequest. See Spring Data Commons, but more flat design and independent of Spring libraries.Container for paging, sorting and filtering params:
- pageNumber: which page to be returned
- pageSize: how many items on one page
- sorting: container for sorting order of result list
- filtering: container for filter criterias of result list
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PageRequest()PageRequest(int pageNumber, int pageSize)Creates a newPageRequest.PageRequest(int pageNumber, int pageSize, Direction direction, String... properties)Creates a newPageRequestwith sort parameters applied.PageRequest(int pageNumber, int pageSize, Sorting sort)PageRequest(int pageNumber, int pageSize, Sorting sort, Filtering filtering)Creates a newPageRequestwith sort parameters applied.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<FilterCriterion>add(Filtering filtering)Add all filter criteria of given filtering to existing filtering.static PageRequestBuilderdefaultBuilder()booleanequals(Object obj)PageRequestfirst()FilteringgetFiltering()intgetOffset()intgetPageNumber()intgetPageSize()SortinggetSorting()inthashCode()booleanhasPrevious()Returns whether there's a previousPageRequestwe can access from the current one.booleanhasSorting()PageRequestnext()PageRequestprevious()Returns thePageResponserequesting the previous page.PageRequestpreviousOrFirst()voidsetFiltering(Filtering filtering)voidsetPageNumber(int pageNumber)voidsetPageSize(int pageSize)voidsetSorting(Sorting sorting)StringtoString()
-
-
-
Constructor Detail
-
PageRequest
public PageRequest()
-
PageRequest
public PageRequest(int pageNumber, int pageSize)Creates a newPageRequest. Pages are zero indexed, thus providing 0 forpagewill return the first page.- Parameters:
pageNumber- zero-based page index.pageSize- the size of the page to be returned.
-
PageRequest
public PageRequest(int pageNumber, int pageSize, Direction direction, String... properties)Creates a newPageRequestwith sort parameters applied.- Parameters:
pageNumber- zero-based page index.pageSize- the size of the page to be returned.direction- the direction of theSortingto be specified, can be null.properties- the properties to sort by, must not be null or empty.
-
PageRequest
public PageRequest(int pageNumber, int pageSize, Sorting sort)
-
PageRequest
public PageRequest(int pageNumber, int pageSize, Sorting sort, Filtering filtering)Creates a newPageRequestwith sort parameters applied.- Parameters:
pageNumber- zero-based page index, must not be less than zero.pageSize- the size of the page to be returned, must not be less than one.sort- can be nullfiltering- contains list of filter criterias
-
-
Method Detail
-
defaultBuilder
public static PageRequestBuilder defaultBuilder()
-
add
public List<FilterCriterion> add(Filtering filtering)
Add all filter criteria of given filtering to existing filtering. Initialise if no existing filtering.- Parameters:
filtering- new filtering criteria to add- Returns:
- complete filtering
-
first
public PageRequest first()
- Returns:
- the
PageRequestrequesting the first page
-
getFiltering
public Filtering getFiltering()
- Returns:
- the filtering parameters
-
getOffset
public int getOffset()
- Returns:
- the offset to be taken according to the underlying page and page size.
-
getPageNumber
public int getPageNumber()
- Returns:
- the page to be returned.
-
getPageSize
public int getPageSize()
- Returns:
- the number of items of that page
-
getSorting
public Sorting getSorting()
- Returns:
- the sorting parameters
-
hasPrevious
public boolean hasPrevious()
Returns whether there's a previousPageRequestwe can access from the current one. Will return false in case the currentPageRequestalready refers to the first page.- Returns:
- whether there's a previous PageRequest
-
hasSorting
public boolean hasSorting()
- Returns:
- whether the page request has defined any sorting.
-
next
public PageRequest next()
- Returns:
- the
PageRequestrequesting the next page
-
previous
public PageRequest previous()
Returns thePageResponserequesting the previous page.- Returns:
- the PageResponse requesting the previous page
-
previousOrFirst
public PageRequest previousOrFirst()
- Returns:
- the previous
PageRequestor the firstPageRequestif the current one already is the first one
-
setFiltering
public void setFiltering(Filtering filtering)
- Parameters:
filtering- the filtering criterias
-
setPageNumber
public void setPageNumber(int pageNumber)
- Parameters:
pageNumber- the page to be returned
-
setPageSize
public void setPageSize(int pageSize)
- Parameters:
pageSize- the number of items of that page
-
setSorting
public void setSorting(Sorting sorting)
- Parameters:
sorting- the sorting parameters
-
-