Class AbstractMcpPromptListChangedMethodCallback
java.lang.Object
org.springaicommunity.mcp.method.changed.prompt.AbstractMcpPromptListChangedMethodCallback
- Direct Known Subclasses:
AsyncMcpPromptListChangedMethodCallback,SyncMcpPromptListChangedMethodCallback
Abstract base class for creating callbacks around prompt list changed consumer methods.
This class provides common functionality for both synchronous and asynchronous prompt
list changed consumer method callbacks. It contains shared logic for method validation,
argument building, and other common operations.
- Author:
- Christian Tzolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAbstractMcpPromptListChangedMethodCallback.AbstractBuilder<T extends AbstractMcpPromptListChangedMethodCallback.AbstractBuilder<T,R>, R> Abstract builder for creating McpPromptListChangedMethodCallback instances.static classException thrown when there is an error invoking a prompt list changed consumer method. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMcpPromptListChangedMethodCallback(Method method, Object bean) Constructor for AbstractMcpPromptListChangedMethodCallback. -
Method Summary
Modifier and TypeMethodDescriptionprotected Object[]buildArgs(Method method, Object exchange, List<io.modelcontextprotocol.spec.McpSchema.Prompt> updatedPrompts) Builds the arguments array for invoking the method.protected voidvalidateMethod(Method method) Validates that the method signature is compatible with the prompt list changed consumer callback.protected voidvalidateParameters(Method method) Validates method parameters.protected abstract voidvalidateReturnType(Method method) Validates that the method return type is compatible with the prompt list changed consumer callback.
-
Field Details
-
method
-
bean
-
-
Constructor Details
-
AbstractMcpPromptListChangedMethodCallback
Constructor for AbstractMcpPromptListChangedMethodCallback.- Parameters:
method- The method to create a callback forbean- The bean instance that contains the method
-
-
Method Details
-
validateMethod
Validates that the method signature is compatible with the prompt list changed consumer callback.This method checks that the return type is valid and that the parameters match the expected pattern.
- Parameters:
method- The method to validate- Throws:
IllegalArgumentException- if the method signature is not compatible
-
validateReturnType
Validates that the method return type is compatible with the prompt list changed consumer callback. This method should be implemented by subclasses to handle specific return type validation.- Parameters:
method- The method to validate- Throws:
IllegalArgumentException- if the return type is not compatible
-
validateParameters
Validates method parameters. This method provides common validation logic.- Parameters:
method- The method to validate- Throws:
IllegalArgumentException- if the parameters are not compatible
-
buildArgs
protected Object[] buildArgs(Method method, Object exchange, List<io.modelcontextprotocol.spec.McpSchema.Prompt> updatedPrompts) Builds the arguments array for invoking the method.This method constructs an array of arguments based on the method's parameter types and the available values.
- Parameters:
method- The method to build arguments forexchange- The server exchangeupdatedPrompts- The updated list of prompts- Returns:
- An array of arguments for the method invocation
-