Package codes.thischwa.cf.model
Class PagingRequest
java.lang.Object
codes.thischwa.cf.model.PagingRequest
Represents a request model for paginated data.
This class encapsulates the page number and the number of items per page for a paginated request, along with utility methods for constructing and retrieving pagination parameters.
Key functionalities:
- Creating a
PagingRequest
instance with specific pagination values using theof
method. - Creating a default
PagingRequest
with predefined pagination values. - Retrieving pagination parameters as a key-value map.
- Generating a query string representation for the pagination parameters.
-
Method Summary
Modifier and TypeMethodDescriptionaddQueryString
(String endpoint) Appends a query string with pagination parameters (page and perPage) to the provided endpoint.static PagingRequest
Creates a defaultPagingRequest
instance with a page number set to 1 and a high number of items per page (5,000,000) to accommodate large dataset requests.Retrieves the pagination parameters in a key-value map format.static PagingRequest
of
(int page, int perPage) Creates a newPagingRequest
instance with the specified page number and items per page.
-
Method Details
-
of
Creates a newPagingRequest
instance with the specified page number and items per page.- Parameters:
page
- the page number to be requestedperPage
- the number of items to be included per page- Returns:
- a new
PagingRequest
instance with the provided parameters
-
defaultPaging
Creates a defaultPagingRequest
instance with a page number set to 1 and a high number of items per page (5,000,000) to accommodate large dataset requests.- Returns:
- a default
PagingRequest
instance with predefined pagination parameters
-
getPagingParams
Retrieves the pagination parameters in a key-value map format.- Returns:
- a map containing the pagination parameters, where the key "page" indicates the current page number and the key "perPage" indicates the number of items per page.
-
addQueryString
Appends a query string with pagination parameters (page and perPage) to the provided endpoint.- Parameters:
endpoint
- the base URL or API endpoint to which the query string will be appended- Returns:
- the complete URL with the appended query string for pagination
-