Class PageRequestImpl
- java.lang.Object
-
- de.digitalcollections.model.impl.paging.PageRequestImpl
-
- All Implemented Interfaces:
PageRequest,Serializable
public class PageRequestImpl extends Object implements PageRequest, Serializable
Basic Java Bean implementation ofPageRequest. See Spring Data Commons, but more flat design and independent of Spring libraries.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.digitalcollections.model.api.paging.PageRequest
PageRequest.Builder
-
-
Constructor Summary
Constructors Constructor Description PageRequestImpl()PageRequestImpl(int page, int size)Creates a newPageRequest.PageRequestImpl(int page, int size, Direction direction, String... properties)Creates a newPageRequestwith sort parameters applied.PageRequestImpl(int page, int size, Sorting sort)Creates a newPageRequestwith sort parameters applied.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)PageRequestfirst()Returns thePageRequestrequesting the first page.intgetOffset()Returns the offset to be taken according to the underlying page and page size.intgetPageNumber()Returns the page to be returned.intgetPageSize()Returns the number of items to be returned.SortinggetSorting()Returns the sorting parameters.inthashCode()booleanhasPrevious()Returns whether there's a previousPageRequestwe can access from the current one.PageRequestnext()Returns thePageRequestrequesting the next page.PageRequestprevious()Returns thePageResponserequesting the previous page.PageRequestpreviousOrFirst()Returns the previousPageRequestor the firstPageRequestif the current one already is the first one.voidsetPageNumber(int page)voidsetPageSize(int size)Sets the number of items.voidsetSorting(Sorting sort)Sets the sorting parameters.StringtoString()
-
-
-
Constructor Detail
-
PageRequestImpl
public PageRequestImpl()
-
PageRequestImpl
public PageRequestImpl(int page, int size)Creates a newPageRequest. Pages are zero indexed, thus providing 0 forpagewill return the first page.- Parameters:
page- zero-based page index.size- the size of the page to be returned.
-
PageRequestImpl
public PageRequestImpl(int page, int size, Direction direction, String... properties)Creates a newPageRequestwith sort parameters applied.- Parameters:
page- zero-based page index.size- the size of the page to be returned.direction- the direction of theSortingImplto be specified, can be null.properties- the properties to sort by, must not be null or empty.
-
PageRequestImpl
public PageRequestImpl(int page, int size, Sorting sort)Creates a newPageRequestwith sort parameters applied.- Parameters:
page- zero-based page index, must not be less than zero.size- the size of the page to be returned, must not be less than one.sort- can be null.
-
-
Method Detail
-
first
public PageRequest first()
Description copied from interface:PageRequestReturns thePageRequestrequesting the first page.- Specified by:
firstin interfacePageRequest- Returns:
- the PageRequest requesting the first page
-
getOffset
public int getOffset()
Description copied from interface:PageRequestReturns the offset to be taken according to the underlying page and page size.- Specified by:
getOffsetin interfacePageRequest- Returns:
- the offset to be taken
-
getPageNumber
public int getPageNumber()
Description copied from interface:PageRequestReturns the page to be returned.- Specified by:
getPageNumberin interfacePageRequest- Returns:
- the page to be returned.
-
getPageSize
public int getPageSize()
Description copied from interface:PageRequestReturns the number of items to be returned.- Specified by:
getPageSizein interfacePageRequest- Returns:
- the number of items of that page
-
getSorting
public Sorting getSorting()
Description copied from interface:PageRequestReturns the sorting parameters.- Specified by:
getSortingin interfacePageRequest- Returns:
- the sorting parameters
-
hasPrevious
public boolean hasPrevious()
Description copied from interface:PageRequestReturns whether there's a previousPageRequestwe can access from the current one. Will return false in case the currentPageRequestalready refers to the first page.- Specified by:
hasPreviousin interfacePageRequest- Returns:
- whether there's a previous PageRequest
-
next
public PageRequest next()
Description copied from interface:PageRequestReturns thePageRequestrequesting the next page.- Specified by:
nextin interfacePageRequest- Returns:
- the PageRequest requesting the next page
-
previous
public PageRequest previous()
Returns thePageResponserequesting the previous page.- Returns:
- the PageResponse requesting the previous page
-
previousOrFirst
public PageRequest previousOrFirst()
Description copied from interface:PageRequestReturns the previousPageRequestor the firstPageRequestif the current one already is the first one.- Specified by:
previousOrFirstin interfacePageRequest- Returns:
- the previous PageRequest or the first PageRequest if the current one already is the first one
-
setPageNumber
public void setPageNumber(int page)
-
setPageSize
public void setPageSize(int size)
Description copied from interface:PageRequestSets the number of items.- Specified by:
setPageSizein interfacePageRequest- Parameters:
size- the number of items of that page
-
setSorting
public void setSorting(Sorting sort)
Description copied from interface:PageRequestSets the sorting parameters.- Specified by:
setSortingin interfacePageRequest- Parameters:
sort- the sorting parameters
-
-