Class PaginatedCollection<TEntries extends EasyPostResource>
java.lang.Object
com.easypost.model.EasyPostResource
com.easypost.model.PaginatedCollection<TEntries>
- Direct Known Subclasses:
AddressCollection, BatchCollection, ChildUserCollection, ClaimCollection, EndShipperCollection, EventCollection, InsuranceCollection, PickupCollection, ReferralCustomerCollection, RefundCollection, ReportCollection, ScanFormCollection, ShipmentCollection, TrackerCollection
public abstract class PaginatedCollection<TEntries extends EasyPostResource>
extends EasyPostResource
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildNextPageParameters(List<TEntries> entries, Integer pageSize) Build the parameters for retrieving the next page of a paginated collection.final <TCollection extends PaginatedCollection<TEntries>>
TCollectiongetNextPage(Function<Map<String, Object>, TCollection> apiCallFunction, List<TEntries> currentEntries) Get the next page of a paginated collection.final <TCollection extends PaginatedCollection<TEntries>>
TCollectiongetNextPage(Function<Map<String, Object>, TCollection> apiCallFunction, List<TEntries> currentEntries, Integer pageSize) Get the next page of a paginated collection with a custom page size.Methods inherited from class EasyPostResource
equals, hashCode, prettyPrint, toString
-
Constructor Details
-
PaginatedCollection
public PaginatedCollection()
-
-
Method Details
-
getNextPage
public final <TCollection extends PaginatedCollection<TEntries>> TCollection getNextPage(Function<Map<String, Object>, TCollection> apiCallFunction, List<TEntries> currentEntries) throws EndOfPaginationErrorGet the next page of a paginated collection.- Type Parameters:
TCollection- The type of the collection to retrieve.- Parameters:
apiCallFunction- The function to call to get the next page.currentEntries- The current entries in the collection. Needed to determine the next page parameters.- Returns:
- The next page of the collection.
- Throws:
EndOfPaginationError- If there are no more pages to retrieve.
-
getNextPage
public final <TCollection extends PaginatedCollection<TEntries>> TCollection getNextPage(Function<Map<String, Object>, TCollection> apiCallFunction, List<TEntries> currentEntries, Integer pageSize) throws EndOfPaginationErrorGet the next page of a paginated collection with a custom page size.- Type Parameters:
TCollection- The type of the collection to retrieve.- Parameters:
apiCallFunction- The function to call to get the next page.currentEntries- The current entries in the collection. Needed to determine the next page parameters.pageSize- The page size to use for the next page.- Returns:
- The next page of the collection.
- Throws:
EndOfPaginationError- If there are no more pages to retrieve.
-
buildNextPageParameters
protected abstract Map<String,Object> buildNextPageParameters(List<TEntries> entries, Integer pageSize) throws EndOfPaginationError Build the parameters for retrieving the next page of a paginated collection.- Parameters:
entries- The current entries in the collection. Needed to determine the next page parameters.pageSize- The page size to use for the next page.- Returns:
- The parameters for retrieving the next page of a paginated collection.
- Throws:
EndOfPaginationError
-