java.lang.Object
org.miaixz.bus.pager.binding.PageObject
Utility class for handling pagination parameter objects. This class provides methods to extract pagination
information from various parameter types, including
Paging objects and objects that can be introspected via
MyBatis's MetaObject.- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static MethodThe `getParameterMap` method of `jakarta.servlet.ServletRequest`, if available.protected static BooleanIndicates whether the application has access to `jakarta.servlet.ServletRequest`.A map storing parameter name mappings for pagination properties.protected static Class<?> The `jakarta.servlet.ServletRequest` class, if available. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Page<T> getPageFromObject(Object params, boolean required) Extracts pagination parameters from an object and creates aPageinstance.protected static ObjectgetParamValue(org.apache.ibatis.reflection.MetaObject paramsObject, String paramName, boolean required) Retrieves a parameter value from aMetaObject.static voidSets custom parameter name mappings for pagination properties.
-
Field Details
-
hasRequest
Indicates whether the application has access to `jakarta.servlet.ServletRequest`. -
requestClass
The `jakarta.servlet.ServletRequest` class, if available. -
getParameterMap
The `getParameterMap` method of `jakarta.servlet.ServletRequest`, if available. -
PARAMS
A map storing parameter name mappings for pagination properties. Keys are common parameter names (e.g., "pageNo"), values are the actual property names.
-
-
Constructor Details
-
PageObject
public PageObject()
-
-
Method Details
-
getPageFromObject
Extracts pagination parameters from an object and creates aPageinstance. It supportsPagingobjects, `jakarta.servlet.ServletRequest` objects, and generic objects that can be introspected by MyBatis's MetaObject.- Type Parameters:
T- the type of elements in the paginated data- Parameters:
params- the parameter object from which to extract pagination informationrequired- if true, throws aPageExceptionif required pagination parameters are missing- Returns:
- a
Pageobject configured with the extracted parameters, or null if no pagination parameters are found and not required - Throws:
org.miaixz.bus.core.lang.exception.PageException- if `params` is null, or if required parameters are missing, or if pagination parameters are not valid numbers
-
getParamValue
protected static Object getParamValue(org.apache.ibatis.reflection.MetaObject paramsObject, String paramName, boolean required) Retrieves a parameter value from aMetaObject.- Parameters:
paramsObject- the MetaObject representing the parameter objectparamName- the name of the parameter to retrieve (e.g., "pageNo", "pageSize")required- if true, throws aPageExceptionif the parameter is not found- Returns:
- the value of the parameter, or null if not found and not required
- Throws:
org.miaixz.bus.core.lang.exception.PageException- if the parameter is required but not found
-
setParams
Sets custom parameter name mappings for pagination properties. The input string should be a semicolon, comma, or ampersand-separated list of key-value pairs, where keys are common parameter names and values are the actual property names. Example: "pageNo=pageNum;pageSize=limit"- Parameters:
params- a string containing custom parameter mappings
-