Package com.tnsai.mcp.model
Class PaginatedResult<T>
java.lang.Object
com.tnsai.mcp.model.PaginatedResult<T>
- Type Parameters:
T- the type of items in the result
Represents a paginated result from MCP list operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetItems()Gets the items in this page.Gets the cursor for the next page.booleanhasMore()Checks if there are more pages available.booleanisEmpty()Checks if this page is empty.<R> PaginatedResult<R> Maps the items to a new type.static <T> PaginatedResult<T> Creates a paginated result with items only (no more pages).static <T> PaginatedResult<T> Creates a paginated result with items and next cursor.intsize()Gets the number of items in this page.toString()
-
Constructor Details
-
PaginatedResult
-
-
Method Details
-
of
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
Creates a paginated result with items and next cursor.- Type Parameters:
T- the item type- Parameters:
items- the itemsnextCursor- the cursor for the next page- Returns:
- a new PaginatedResult
-
getItems
Gets the items in this page.- Returns:
- the list of items
-
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
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
-