Class PaginationWalker

java.lang.Object
dev.getelements.elements.sdk.model.util.PaginationWalker

public class PaginationWalker extends Object
Walks set of data that is managed through a Pagination.
  • Constructor Details

    • PaginationWalker

      public PaginationWalker()
  • Method Details

    • withCount

      public PaginationWalker withCount(int count)
      Specifies the count on each page fetch.
      Parameters:
      count - the count
      Returns:
      this instance
    • withOffset

      public PaginationWalker withOffset(int offset)
      Specifies the offset on each page fetch.
      Parameters:
      offset - the offset
      Returns:
      this instance
    • withTotal

      public PaginationWalker withTotal(int total)
      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 paginated
      AggregateT - the aggregate type
      Parameters:
      initial - the initial aggregate value
      walkFunction - the walk function
      aggregatorFunction - the aggregator function
      Returns:
      the aggregate
    • toList

      public <PaginatedT> List<PaginatedT> toList(PaginationWalker.WalkFunction<PaginatedT> walkFunction)
      Aggregates several pages to a list.
      Type Parameters:
      PaginatedT - the paginated type
      Parameters:
      walkFunction - the walk function
      Returns:
      a List with 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 -