Class PaginatedResult<T>

java.lang.Object
com.tnsai.mcp.model.PaginatedResult<T>
Type Parameters:
T - the type of items in the result

public class PaginatedResult<T> extends Object
Represents a paginated result from MCP list operations.
  • Constructor Details

    • PaginatedResult

      public PaginatedResult(List<T> items, String nextCursor)
  • Method Details

    • of

      public static <T> PaginatedResult<T> of(List<T> items)
      Creates a paginated result with items only (no more pages).
      Type Parameters:
      T - the item type
      Parameters:
      items - the items
      Returns:
      a new PaginatedResult
    • of

      public static <T> PaginatedResult<T> of(List<T> items, String nextCursor)
      Creates a paginated result with items and next cursor.
      Type Parameters:
      T - the item type
      Parameters:
      items - the items
      nextCursor - the cursor for the next page
      Returns:
      a new PaginatedResult
    • getItems

      public List<T> getItems()
      Gets the items in this page.
      Returns:
      the list of items
    • getNextCursor

      public String getNextCursor()
      Gets the cursor for the next page.
      Returns:
      the next cursor, or null if this is the last page
    • hasMore

      public boolean hasMore()
      Checks if there are more pages available.
      Returns:
      true if there is a next page
    • size

      public int size()
      Gets the number of items in this page.
      Returns:
      the item count
    • isEmpty

      public boolean isEmpty()
      Checks if this page is empty.
      Returns:
      true if there are no items
    • map

      public <R> PaginatedResult<R> map(Function<T,R> mapper)
      Maps the items to a new type.
      Type Parameters:
      R - the new item type
      Parameters:
      mapper - the mapping function
      Returns:
      a new PaginatedResult with mapped items
    • toString

      public String toString()
      Overrides:
      toString in class Object