Class A2AResponse<T>

java.lang.Object
org.a2aproject.sdk.jsonrpc.common.wrappers.A2AResponse<T>
Type Parameters:
T - the type of the result value returned in successful responses
All Implemented Interfaces:
A2AMessage
Direct Known Subclasses:
A2AErrorResponse, CancelTaskResponse, CreateTaskPushNotificationConfigResponse, DeleteTaskPushNotificationConfigResponse, GetExtendedAgentCardResponse, GetTaskPushNotificationConfigResponse, GetTaskResponse, ListTaskPushNotificationConfigsResponse, ListTasksResponse, SendMessageResponse, SendStreamingMessageResponse

Represents a JSONRPC response.
  • Field Details

    • jsonrpc

      protected String jsonrpc
      The JSON-RPC protocol version.
    • id

      protected Object id
      The request identifier this response corresponds to.
    • result

      protected T result
      The result of the method invocation.
    • error

      protected A2AError error
      The error object if the invocation failed.
  • Constructor Details

    • A2AResponse

      public A2AResponse()
      Default constructor for deserialization.
    • A2AResponse

      public A2AResponse(String jsonrpc, Object id, T result, A2AError error, Class<T> resultType)
      Constructs a JSON-RPC response.
      Parameters:
      jsonrpc - the JSON-RPC version
      id - the request ID
      result - the result value
      error - the error if any
      resultType - the result type class
  • Method Details

    • getJsonrpc

      public String getJsonrpc()
      Description copied from interface: A2AMessage
      Gets the JSON-RPC version for this message.

      According to the JSON-RPC 2.0 specification, this must be exactly "2.0".

      Specified by:
      getJsonrpc in interface A2AMessage
      Returns:
      the JSON-RPC version string, always "2.0"
    • getId

      public Object getId()
      Description copied from interface: A2AMessage
      Gets the request/response correlation identifier.

      The ID is used to match responses with their corresponding requests. It may be a String, Integer, or null for notification-style requests that do not expect a response.

      Specified by:
      getId in interface A2AMessage
      Returns:
      the correlation ID, or null for notifications
    • getResult

      public T getResult()
      Gets the result value.
      Returns:
      the result
    • getError

      public A2AError getError()
      Gets the error object.
      Returns:
      the error if any