Class PaginationWalker
java.lang.Object
dev.getelements.elements.sdk.model.util.PaginationWalker
Walks set of data that is managed through a
Pagination.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceUsed to fetch the next page of a collection. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<PaginatedT,AggregateT>
AggregateTaggregate(AggregateT initial, PaginationWalker.WalkFunction<PaginatedT> walkFunction, BiFunction<AggregateT, Pagination<PaginatedT>, AggregateT> aggregatorFunction) Aggregates the result of many paginations.<PaginatedT>
voidforEach(PaginationWalker.WalkFunction<PaginatedT> walkFunction, Consumer<PaginatedT> tConsumer) Walks a dataset passing each object from each page into the<PaginatedT>
List<PaginatedT> toList(PaginationWalker.WalkFunction<PaginatedT> walkFunction) Aggregates several pages to a list.withCount(int count) Specifies the count on each page fetch.withOffset(int offset) Specifies the offset on each page fetch.withTotal(int total) Specifies the maximum total to fetch
-
Constructor Details
-
PaginationWalker
public PaginationWalker()
-
-
Method Details
-
withCount
Specifies the count on each page fetch.- Parameters:
count- the count- Returns:
- this instance
-
withOffset
Specifies the offset on each page fetch.- Parameters:
offset- the offset- Returns:
- this instance
-
withTotal
Specifies the maximum total to fetch- Parameters:
total- the total- Returns:
- this instance
-
aggregate
public <PaginatedT,AggregateT> AggregateT aggregate(AggregateT initial, PaginationWalker.WalkFunction<PaginatedT> walkFunction, BiFunction<AggregateT, Pagination<PaginatedT>, AggregateT> aggregatorFunction) Aggregates the result of many paginations.- Type Parameters:
PaginatedT- the type which is paginatedAggregateT- the aggregate type- Parameters:
initial- the initial aggregate valuewalkFunction- the walk functionaggregatorFunction- the aggregator function- Returns:
- the aggregate
-
toList
Aggregates several pages to a list.- Type Parameters:
PaginatedT- the paginated type- Parameters:
walkFunction- the walk function- Returns:
- a
Listwith all known entries
-
forEach
public <PaginatedT> void forEach(PaginationWalker.WalkFunction<PaginatedT> walkFunction, Consumer<PaginatedT> tConsumer) Walks a dataset passing each object from each page into the- Type Parameters:
PaginatedT-- Parameters:
walkFunction-tConsumer-
-