Class DefaultPageRequest
java.lang.Object
com.broadleafcommerce.data.tracking.core.filtering.DefaultPageRequest
- All Implemented Interfaces:
Serializable
,org.springframework.data.domain.Pageable
public final class DefaultPageRequest
extends Object
implements org.springframework.data.domain.Pageable, Serializable
Pageable
implementation used to differentiate default PageRequests
from specialized Broadleaf use-cases. The usual use-case is to represent a request made with no
explicit pagination info. This signals to the NarrowExecutor
that this can be safely
converted to a NarrowedPageable
to fetch the first page or results with the default page
size, whereas a PageRequest
would indicate that a request with explicit pagination info
has been made but the info was too incomplete to create a NarrowedPageable
(usually
because of a missing offset value), which the NarrowExecutor
cannot reliably handle.- Author:
- Nathan Moore (nathandmoore)
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionA new page request starting at 0 and containinggetDefaultSize()
elementsDefaultPageRequest
(int page, int size) A new page request with no sortingDefaultPageRequest
(Integer page, Integer size, org.springframework.data.domain.Sort sort) A page request that includes sortingDefaultPageRequest
(Integer page, Integer size, org.springframework.data.domain.Sort sort, PageableProperties pageableProperties) A page request that includes sorting -
Method Summary
Modifier and TypeMethodDescriptionboolean
org.springframework.data.domain.PageRequest
first()
protected int
Determines the default page size.protected org.springframework.data.domain.Sort
Determines the defaultSort
.protected int
Determines the default max page size allowed.long
int
org.springframework.data.domain.PageRequest
int
org.springframework.data.domain.Sort
getSort()
org.springframework.data.domain.Sort
getSortOr
(org.springframework.data.domain.Sort sort) int
hashCode()
boolean
boolean
isPaged()
boolean
org.springframework.data.domain.PageRequest
next()
org.springframework.data.domain.PageRequest
previous()
org.springframework.data.domain.Pageable
Optional<org.springframework.data.domain.Pageable>
org.springframework.data.domain.OffsetScrollPosition
toString()
org.springframework.data.domain.PageRequest
withPage
(int pageNumber) org.springframework.data.domain.PageRequest
withSort
(org.springframework.data.domain.Sort sort) org.springframework.data.domain.PageRequest
-
Field Details
-
DEFAULT_MAX_SIZE
public static final int DEFAULT_MAX_SIZE- See Also:
-
DEFAULT_SIZE
public static final int DEFAULT_SIZE- See Also:
-
-
Constructor Details
-
DefaultPageRequest
public DefaultPageRequest()A new page request starting at 0 and containinggetDefaultSize()
elements -
DefaultPageRequest
public DefaultPageRequest(int page, int size) A new page request with no sorting- Parameters:
page
- zero-based page index, must not be negativesize
- The size of the page to be returned, must not be negative. If it is greater than the maximum page size that is gotten from the passedPageableProperties
, thePageableProperties
configured maximum page size will be used instead
-
DefaultPageRequest
public DefaultPageRequest(@Nullable Integer page, @Nullable Integer size, @Nullable org.springframework.data.domain.Sort sort) A page request that includes sorting- Parameters:
page
- zero-based page index, must not be negative. If null, defaults to 0size
- the size of the page to be returned. If null, defaults togetDefaultSize()
. If the passed size is greater than the default maximum page size, the default maximum page size will be used insteadsort
-Sort
for the request. If null, forced togetDefaultSort()
.
-
DefaultPageRequest
public DefaultPageRequest(@Nullable Integer page, @Nullable Integer size, @Nullable org.springframework.data.domain.Sort sort, @Nullable PageableProperties pageableProperties) A page request that includes sorting- Parameters:
page
- zero-based page index, must not be negative. If null, defaults to 0size
- the size of the page to be returned. If null, defaults togetDefaultSize()
. If the passed size is greater than the default maximum page size or the size that is gotten from the passedPageableProperties
, the default maximum page size or thePageableProperties
configured maximum page size will be used insteadsort
-Sort
for the request. If null, forced togetDefaultSort()
.pageableProperties
- properties for pageable operations
-
-
Method Details
-
getMaxSize
protected int getMaxSize()Determines the default max page size allowed. Default isDEFAULT_SIZE
.- Returns:
- the default max page size allowed
-
getDefaultSize
protected int getDefaultSize()Determines the default page size. Default isDEFAULT_SIZE
.- Returns:
- the default page size
-
getDefaultSort
protected org.springframework.data.domain.Sort getDefaultSort()Determines the defaultSort
. Default isSort.unsorted()
.- Returns:
- the default
Sort
-
getPageRequest
public org.springframework.data.domain.PageRequest getPageRequest() -
equals
-
hashCode
public int hashCode() -
toString
-
getSort
public org.springframework.data.domain.Sort getSort()- Specified by:
getSort
in interfaceorg.springframework.data.domain.Pageable
-
next
public org.springframework.data.domain.PageRequest next()- Specified by:
next
in interfaceorg.springframework.data.domain.Pageable
-
previous
public org.springframework.data.domain.PageRequest previous() -
first
public org.springframework.data.domain.PageRequest first()- Specified by:
first
in interfaceorg.springframework.data.domain.Pageable
-
withPage
public org.springframework.data.domain.PageRequest withPage(int pageNumber) - Specified by:
withPage
in interfaceorg.springframework.data.domain.Pageable
-
withSort
public org.springframework.data.domain.PageRequest withSort(org.springframework.data.domain.Sort.Direction direction, String... properties) -
withSort
public org.springframework.data.domain.PageRequest withSort(org.springframework.data.domain.Sort sort) -
getPageSize
public int getPageSize()- Specified by:
getPageSize
in interfaceorg.springframework.data.domain.Pageable
-
getPageNumber
public int getPageNumber()- Specified by:
getPageNumber
in interfaceorg.springframework.data.domain.Pageable
-
getOffset
public long getOffset()- Specified by:
getOffset
in interfaceorg.springframework.data.domain.Pageable
-
hasPrevious
public boolean hasPrevious()- Specified by:
hasPrevious
in interfaceorg.springframework.data.domain.Pageable
-
previousOrFirst
public org.springframework.data.domain.Pageable previousOrFirst()- Specified by:
previousOrFirst
in interfaceorg.springframework.data.domain.Pageable
-
isPaged
public boolean isPaged()- Specified by:
isPaged
in interfaceorg.springframework.data.domain.Pageable
-
isUnpaged
public boolean isUnpaged()- Specified by:
isUnpaged
in interfaceorg.springframework.data.domain.Pageable
-
getSortOr
public org.springframework.data.domain.Sort getSortOr(org.springframework.data.domain.Sort sort) - Specified by:
getSortOr
in interfaceorg.springframework.data.domain.Pageable
-
toOptional
- Specified by:
toOptional
in interfaceorg.springframework.data.domain.Pageable
-
toScrollPosition
public org.springframework.data.domain.OffsetScrollPosition toScrollPosition()- Specified by:
toScrollPosition
in interfaceorg.springframework.data.domain.Pageable
-