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 defaultPageRequests
from specialized Broadleaf use-cases. The usual use-case is to represent a request made with no explicit pagination info. This signals to theNarrowExecutor
that this can be safely converted to aNarrowedPageable
to fetch the first page or results with the default page size, whereas aPageRequest
would indicate that a request with explicit pagination info has been made but the info was too incomplete to create aNarrowedPageable
(usually because of a missing offset value), which theNarrowExecutor
cannot reliably handle.- Author:
- Nathan Moore (nathandmoore)
- See Also:
NarrowPageableHandlerMethodArgumentResolver
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_SIZE
static int
DEFAULT_SIZE
-
Constructor Summary
Constructors Constructor Description DefaultPageRequest()
A 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 sorting
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
org.springframework.data.domain.Pageable
first()
protected int
getDefaultSize()
Determines the default page size.protected org.springframework.data.domain.Sort
getDefaultSort()
Determines the defaultSort
.protected int
getMaxSize()
Determines the default max page size allowed.long
getOffset()
int
getPageNumber()
org.springframework.data.domain.PageRequest
getPageRequest()
int
getPageSize()
org.springframework.data.domain.Sort
getSort()
org.springframework.data.domain.Sort
getSortOr(org.springframework.data.domain.Sort sort)
int
hashCode()
boolean
hasPrevious()
boolean
isPaged()
boolean
isUnpaged()
org.springframework.data.domain.Pageable
next()
org.springframework.data.domain.PageRequest
previous()
org.springframework.data.domain.Pageable
previousOrFirst()
Optional<org.springframework.data.domain.Pageable>
toOptional()
String
toString()
-
-
-
Field Detail
-
DEFAULT_MAX_SIZE
public static final int DEFAULT_MAX_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_SIZE
public static final int DEFAULT_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 greater thangetMaxSize()
, forced togetMaxSize()
.
-
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 greater thangetMaxSize()
, forced togetMaxSize()
.sort
-Sort
for the request. If null, forced togetDefaultSort()
.
-
-
Method Detail
-
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()
-
getSort
public org.springframework.data.domain.Sort getSort()
- Specified by:
getSort
in interfaceorg.springframework.data.domain.Pageable
-
next
public org.springframework.data.domain.Pageable next()
- Specified by:
next
in interfaceorg.springframework.data.domain.Pageable
-
previous
public org.springframework.data.domain.PageRequest previous()
-
first
public org.springframework.data.domain.Pageable first()
- Specified by:
first
in interfaceorg.springframework.data.domain.Pageable
-
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
public Optional<org.springframework.data.domain.Pageable> toOptional()
- Specified by:
toOptional
in interfaceorg.springframework.data.domain.Pageable
-
-