Class ResultsPageTracker<ProgressParamT extends java.lang.Number>
- java.lang.Object
-
- com.stackone.stackone_client_java.utils.pagination.ResultsPageTracker<ProgressParamT>
-
- Type Parameters:
ProgressParamT- The numeric type to use for page numbers (e.g., Integer, Long)
- All Implemented Interfaces:
ProgressTrackerStrategy<ProgressParamT>
public class ResultsPageTracker<ProgressParamT extends java.lang.Number> extends java.lang.Object implements ProgressTrackerStrategy<ProgressParamT>
Handles pagination using a results expression to determine termination. This tracker is suitable for APIs that return a count of items in each response and use that to determine if there are more pages, while maintaining monotonic page number increments.
-
-
Constructor Summary
Constructors Constructor Description ResultsPageTracker(java.lang.String resultSizeExpression, java.lang.Class<ProgressParamT> pageType, long fromPage, long minItems)Creates a new ResultsExpressionPageTracker with a specified starting page.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadvance(com.jayway.jsonpath.ReadContext respJson)Process the response and update pagination state.ProgressParamTgetPosition()Get the current progression value to use in the next request.
-
-
-
Constructor Detail
-
ResultsPageTracker
public ResultsPageTracker(java.lang.String resultSizeExpression, java.lang.Class<ProgressParamT> pageType, long fromPage, long minItems)Creates a new ResultsExpressionPageTracker with a specified starting page.- Parameters:
resultSizeExpression- The JsonPath expression to extract result countpageType- The class of the numeric type to use (e.g., Integer.class, Long.class)fromPage- Page number to start pagination from (0-based or 1-based, depending on API)minItems- Minimum number of items required to continue pagination
-
-
Method Detail
-
advance
public boolean advance(com.jayway.jsonpath.ReadContext respJson)
Description copied from interface:ProgressTrackerStrategyProcess the response and update pagination state. This method should: 1. Extract pagination metadata from the response 2. Update internal state based on the metadata 3. Return true if there are more pages to fetch, false otherwise- Specified by:
advancein interfaceProgressTrackerStrategy<ProgressParamT extends java.lang.Number>- Parameters:
respJson- The JSON response to process- Returns:
- true if there are more pages to fetch, false otherwise
-
getPosition
public ProgressParamT getPosition()
Description copied from interface:ProgressTrackerStrategyGet the current progression value to use in the next request. This value will be used to modify the request for the next page.- Specified by:
getPositionin interfaceProgressTrackerStrategy<ProgressParamT extends java.lang.Number>- Returns:
- The current progression value
-
-