Class Pagination<T>

java.lang.Object
dev.getelements.elements.sdk.model.Pagination<T>
Type Parameters:
T - the element type
All Implemented Interfaces:
Serializable, Iterable<T>
Direct Known Subclasses:
AuthSchemePagination, DistinctInventoryItemPagination, ElementsSmartContractPagination, InventoryItemPagination, ItemLedgerEntryPagination, LargeObjectPagination, MetadataPagination, MetadataSpecPagination, MongoRankDao.MongoRankPagination, MultiMatchPagination, ProductBundlePagination, ProductSkuSchemaPagination, ProfilePagination, ProgressPagination, ReceiptPagination, SaveDataDocumentPagination, ScheduleEventPagination, SchedulePagination, SmartContractPagination, VaultPagination, WalletPagination

public class Pagination<T> extends Object implements Iterable<T>, Serializable
Represents a paginated result set with offset and total count.
See Also:
  • Constructor Details

    • Pagination

      public Pagination()
      Creates a new instance.
  • Method Details

    • empty

      public static <T> Pagination<T> empty()
      Returns an empty pagination with no results.
      Type Parameters:
      T - the result type
      Returns:
      an empty pagination
    • getOffset

      public int getOffset()
      Returns the current page offset.
      Returns:
      the offset
    • setOffset

      public void setOffset(int offset)
      Sets the current page offset.
      Parameters:
      offset - the offset
    • getTotal

      public int getTotal()
      Returns the total number of results.
      Returns:
      the total count
    • setTotal

      public void setTotal(int total)
      Sets the total number of results.
      Parameters:
      total - the total count
    • getObjects

      public List<T> getObjects()
      Returns the objects in this page.
      Returns:
      the objects
    • setObjects

      public void setObjects(List<T> objects)
      Sets the objects in this page.
      Parameters:
      objects - the objects
    • isApproximation

      public boolean isApproximation()
      Returns whether the total is an approximation.
      Returns:
      true if the total is an approximation
    • setApproximation

      public void setApproximation(boolean approximation)
      Sets whether the total is an approximation.
      Parameters:
      approximation - true if the total is an approximation
    • from

      public static <U> Pagination<U> from(Stream<U> uStream)
      Creates a Pagination from a stream, collecting all elements.
      Type Parameters:
      U - the element type
      Parameters:
      uStream - the stream of elements
      Returns:
      a Pagination containing all stream elements
    • transform

      public <U> Pagination<U> transform(Function<T,U> function)
      Transforms this pagination by applying a function to each element.
      Type Parameters:
      U - the target element type
      Parameters:
      function - the transformation function
      Returns:
      a new Pagination with transformed elements
    • stream

      public Stream<T> stream()
      Returns a sequential stream of the objects in this page.
      Returns:
      a stream of objects
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object