Class 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:
    NarrowPageableHandlerMethodArgumentResolver, Serialized Form
    • Constructor Detail

      • DefaultPageRequest

        public DefaultPageRequest()
        A new page request starting at 0 and containing getDefaultSize() elements
      • DefaultPageRequest

        public DefaultPageRequest​(int page,
                                  int size)
        A new page request with no sorting
        Parameters:
        page - zero-based page index, must not be negative
        size - The size of the page to be returned, must not be negative. If greater than getMaxSize(), forced to getMaxSize().
      • 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 0
        size - the size of the page to be returned. If null, defaults to getDefaultSize() If greater than getMaxSize(), forced to getMaxSize().
        sort - Sort for the request. If null, forced to getDefaultSort().
    • Method Detail

      • getMaxSize

        protected int getMaxSize()
        Determines the default max page size allowed. Default is DEFAULT_SIZE.
        Returns:
        the default max page size allowed
      • getDefaultSize

        protected int getDefaultSize()
        Determines the default page size. Default is DEFAULT_SIZE.
        Returns:
        the default page size
      • getDefaultSort

        protected org.springframework.data.domain.Sort getDefaultSort()
        Determines the default Sort. Default is Sort.unsorted().
        Returns:
        the default Sort
      • getPageRequest

        public org.springframework.data.domain.PageRequest getPageRequest()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getSort

        public org.springframework.data.domain.Sort getSort()
        Specified by:
        getSort in interface org.springframework.data.domain.Pageable
      • next

        public org.springframework.data.domain.Pageable next()
        Specified by:
        next in interface org.springframework.data.domain.Pageable
      • previous

        public org.springframework.data.domain.PageRequest previous()
      • first

        public org.springframework.data.domain.Pageable first()
        Specified by:
        first in interface org.springframework.data.domain.Pageable
      • getPageSize

        public int getPageSize()
        Specified by:
        getPageSize in interface org.springframework.data.domain.Pageable
      • getPageNumber

        public int getPageNumber()
        Specified by:
        getPageNumber in interface org.springframework.data.domain.Pageable
      • getOffset

        public long getOffset()
        Specified by:
        getOffset in interface org.springframework.data.domain.Pageable
      • hasPrevious

        public boolean hasPrevious()
        Specified by:
        hasPrevious in interface org.springframework.data.domain.Pageable
      • previousOrFirst

        public org.springframework.data.domain.Pageable previousOrFirst()
        Specified by:
        previousOrFirst in interface org.springframework.data.domain.Pageable
      • isPaged

        public boolean isPaged()
        Specified by:
        isPaged in interface org.springframework.data.domain.Pageable
      • isUnpaged

        public boolean isUnpaged()
        Specified by:
        isUnpaged in interface org.springframework.data.domain.Pageable
      • getSortOr

        public org.springframework.data.domain.Sort getSortOr​(org.springframework.data.domain.Sort sort)
        Specified by:
        getSortOr in interface org.springframework.data.domain.Pageable
      • toOptional

        public Optional<org.springframework.data.domain.Pageable> toOptional()
        Specified by:
        toOptional in interface org.springframework.data.domain.Pageable