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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionA 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 TypeMethodDescriptionbooleanorg.springframework.data.domain.PageRequestfirst()protected intDetermines the default page size.protected org.springframework.data.domain.SortDetermines the defaultSort.protected intDetermines the default max page size allowed.longintorg.springframework.data.domain.PageRequestintorg.springframework.data.domain.SortgetSort()org.springframework.data.domain.SortgetSortOr(org.springframework.data.domain.Sort sort) inthashCode()booleanbooleanisPaged()booleanorg.springframework.data.domain.PageRequestnext()org.springframework.data.domain.PageRequestprevious()org.springframework.data.domain.PageableOptional<org.springframework.data.domain.Pageable>org.springframework.data.domain.OffsetScrollPositiontoString()org.springframework.data.domain.PageRequestwithPage(int pageNumber) org.springframework.data.domain.PageRequestwithSort(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, thePageablePropertiesconfigured 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-Sortfor 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 thePageablePropertiesconfigured maximum page size will be used insteadsort-Sortfor 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:
getSortin interfaceorg.springframework.data.domain.Pageable
-
next
public org.springframework.data.domain.PageRequest next()- Specified by:
nextin interfaceorg.springframework.data.domain.Pageable
-
previous
public org.springframework.data.domain.PageRequest previous() -
first
public org.springframework.data.domain.PageRequest first()- Specified by:
firstin interfaceorg.springframework.data.domain.Pageable
-
withPage
public org.springframework.data.domain.PageRequest withPage(int pageNumber) - Specified by:
withPagein 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:
getPageSizein interfaceorg.springframework.data.domain.Pageable
-
getPageNumber
public int getPageNumber()- Specified by:
getPageNumberin interfaceorg.springframework.data.domain.Pageable
-
getOffset
public long getOffset()- Specified by:
getOffsetin interfaceorg.springframework.data.domain.Pageable
-
hasPrevious
public boolean hasPrevious()- Specified by:
hasPreviousin interfaceorg.springframework.data.domain.Pageable
-
previousOrFirst
public org.springframework.data.domain.Pageable previousOrFirst()- Specified by:
previousOrFirstin interfaceorg.springframework.data.domain.Pageable
-
isPaged
public boolean isPaged()- Specified by:
isPagedin interfaceorg.springframework.data.domain.Pageable
-
isUnpaged
public boolean isUnpaged()- Specified by:
isUnpagedin interfaceorg.springframework.data.domain.Pageable
-
getSortOr
public org.springframework.data.domain.Sort getSortOr(org.springframework.data.domain.Sort sort) - Specified by:
getSortOrin interfaceorg.springframework.data.domain.Pageable
-
toOptional
- Specified by:
toOptionalin interfaceorg.springframework.data.domain.Pageable
-
toScrollPosition
public org.springframework.data.domain.OffsetScrollPosition toScrollPosition()- Specified by:
toScrollPositionin interfaceorg.springframework.data.domain.Pageable
-