Spring Data for VMware GemFire
Class PagingUtils
java.lang.Object
org.springframework.data.gemfire.repository.query.support.PagingUtils
- Since:
- 2.4.0
- See Also:
-
CollectionPagePageableQueryMethod
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertPageable(org.springframework.data.domain.Pageable pageable) Asserts that thePageableobject is valid.static <T> List<T>getPagedList(List<T> list, org.springframework.data.domain.Pageable pageable) Gets a page from the givenList.static org.springframework.data.domain.PageablegetPageRequest(org.springframework.data.repository.query.QueryMethod queryMethod, Object... arguments) Finds thepage requestargument from an array of arguments passed to the givenQueryMethod.static intgetQueryResultSetEndIndexForPage(org.springframework.data.domain.Pageable pageable) Null-safe method used to determine the end index in the query result set for populating the content of thePage.static intgetQueryResultSetLimitForPage(org.springframework.data.domain.Pageable pageable) Null-safe method used to determine the maximum results that would be returned by a query given thePageableobject specifying the requestedPage.static intgetQueryResultSetStartIndexForPage(org.springframework.data.domain.Pageable pageable) Null-safe method used to determine the starting index in the query result set for populating the content of thePage.static booleanisPageOne(org.springframework.data.domain.Pageable pageable) Null-safe method to determine whether the givenpage requestis for page one.static booleanisPagingPresent(org.springframework.data.repository.query.QueryMethod queryMethod) Null-safe method used to determine whether the givenQueryMethodrepresents (models) a paged query.protected static intnormalize(int pageNumber) Normalizes 0 index based page numbers (i.e.static intnormalizePageNumber(org.springframework.data.domain.Page<?> page) Null-safe method used to normalize 0 index based page numbers (i.e.static intnormalizePageNumber(org.springframework.data.domain.Pageable pageable) Null-safe method used to normalize 0 index based page numbers (i.e.protected static longnullSafeSize(Iterable<?> iterable) Null-safe method to determine the size (number of elements) of theIterable.static <T> org.springframework.data.domain.Page<T>
-
Field Details
-
INVALID_PAGE_NUMBER_MESSAGE
- See Also:
-
INVALID_PAGE_SIZE_MESSAGE
- See Also:
-
NON_NULL_PAGEABLE_MESSAGE
- See Also:
-
DEFAULT_IS_PAGE_QUERY_FUNCTION
-
-
Constructor Details
-
PagingUtils
public PagingUtils()
-
-
Method Details
-
assertPageable
public static void assertPageable(@NonNull org.springframework.data.domain.Pageable pageable) Asserts that thePageableobject is valid.- Parameters:
pageable-Pageableobject to evaluate.- Throws:
IllegalArgumentException- ifPageableis null or page number is less than 0 or the page size is less than 1.- See Also:
-
Pageable
-
isPageOne
public static boolean isPageOne(@NonNull org.springframework.data.domain.Pageable pageable) Null-safe method to determine whether the givenpage requestis for page one.- Parameters:
pageable-page requestto evaluate.- Returns:
- a boolean value indicating whether the given
page requestis for page one. - See Also:
-
Pageable
-
isPagingPresent
public static boolean isPagingPresent(@Nullable org.springframework.data.repository.query.QueryMethod queryMethod) Null-safe method used to determine whether the givenQueryMethodrepresents (models) a paged query.- Parameters:
queryMethod-QueryMethodto evaluate for paging.- Returns:
- a boolean value indicating whether the given
QueryMethodrepresents (models) a paged query. - See Also:
-
QueryMethod
-
getPagedList
@NonNull public static <T> List<T> getPagedList(@NonNull List<T> list, @NonNull org.springframework.data.domain.Pageable pageable) Gets a page from the givenList. This method is null-safe, and guards against a nullListandPageable.- Type Parameters:
T-typeof theListelements; must not be null.- Parameters:
list-Listfrom which to extract a page of elements; must not be null.pageable-Pageableobject encapsulating the details for the page requested.- Returns:
- a
sub-Listcontaining the contents for the requested page. - See Also:
-
getPageRequest
@NonNull public static org.springframework.data.domain.Pageable getPageRequest(@NonNull org.springframework.data.repository.query.QueryMethod queryMethod, @NonNull Object... arguments) Finds thepage requestargument from an array of arguments passed to the givenQueryMethod.- Parameters:
queryMethod- invokedQueryMethod; must not be null.arguments- array ofargumentspassed to theQueryMethod; must not be null.- Returns:
- the
page requestargument in the array ofargumentspassed to theQueryMethod. - Throws:
IllegalArgumentException- ifQueryMethodis null, or theQueryMethodparameter count is not equal to the argument count, or the indexedQueryMethodargument is not an instance ofPageable.IllegalStateException- if theQueryMethoddoes not have aPageableparameter.- See Also:
-
QueryMethodPageable
-
getQueryResultSetStartIndexForPage
public static int getQueryResultSetStartIndexForPage(@Nullable org.springframework.data.domain.Pageable pageable) Null-safe method used to determine the starting index in the query result set for populating the content of thePage.- Parameters:
pageable-Pageableobject encapsulating the details of the requestedPage.- Returns:
- the start index in the query result set to populate the content of the
Page. - See Also:
-
getQueryResultSetEndIndexForPage
public static int getQueryResultSetEndIndexForPage(@Nullable org.springframework.data.domain.Pageable pageable) Null-safe method used to determine the end index in the query result set for populating the content of thePage.- Parameters:
pageable-Pageableobject encapsulating the details of the requestedPage.- Returns:
- the end index in the query result set to populate the content of the
Page. - See Also:
-
getQueryResultSetLimitForPage
public static int getQueryResultSetLimitForPage(@Nullable org.springframework.data.domain.Pageable pageable) Null-safe method used to determine the maximum results that would be returned by a query given thePageableobject specifying the requestedPage.- Parameters:
pageable-Pageableobject encapsulating the details of the requestedPage.- Returns:
- the maximum results that would be returned by a query given the
Pageableobject specifying the requestedPage. - See Also:
-
PageablenormalizePageNumber(Pageable)
-
normalizePageNumber
public static int normalizePageNumber(@Nullable org.springframework.data.domain.Page<?> page) Null-safe method used to normalize 0 index based page numbers (i.e. 0, 1, 2, ...) to natural page numbers (i.e. 1, 2, 3, ...) using the givenPage.- Parameters:
page-Pageused to determine the page number to normalize.- Returns:
- the normalized page number from the 0 index based page number.
- See Also:
-
Pagenormalize(int)
-
normalizePageNumber
public static int normalizePageNumber(@Nullable org.springframework.data.domain.Pageable pageable) Null-safe method used to normalize 0 index based page numbers (i.e. 0, 1, 2, ...) to natural page numbers (i.e. 1, 2, 3, ...) using the givenPageable.- Parameters:
pageable-Pageableused to determine the page number to normalize.- Returns:
- the normalized page number from the 0 index based page number.
- See Also:
-
Pageablenormalize(int)
-
normalize
protected static int normalize(int pageNumber) Normalizes 0 index based page numbers (i.e. 0, 1, 2, ...) to natural page numbers (i.e. 1, 2, 3, ...).- Parameters:
pageNumber- Thepage numberto normalize.- Returns:
- the normalized page number from the 0 index based page number.
-
nullSafeSize
Null-safe method to determine the size (number of elements) of theIterable. TheIterableobject may be an array, aCollectionor simply a stream backing, pureIterableobject. -
toPage
@NonNull public static <T> org.springframework.data.domain.Page<T> toPage(@NonNull List<T> list, @NonNull org.springframework.data.domain.Pageable pageable) - Type Parameters:
T-typeof theListelements.- Parameters:
list-Listof content from which to extract aPage; must not be null.pageable-Pageableobject encapsulating the details of thePagerequested; must not be null.- Returns:
- a non-null
Pageview from the givenListbased on thePageableobject (page request). - See Also:
-
PageablePagegetPagedList(List, Pageable)List
-