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 Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.a2aproject.sdk.spec.A2AError
    The error object if the invocation failed.
    protected Object
    The request identifier this response corresponds to.
    protected String
    The JSON-RPC protocol version.
    protected T
    The result of the method invocation.

    Fields inherited from interface org.a2aproject.sdk.jsonrpc.common.wrappers.A2AMessage

    JSONRPC_VERSION
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for deserialization.
    A2AResponse(String jsonrpc, Object id, T result, org.a2aproject.sdk.spec.A2AError error, Class<T> resultType)
    Constructs a JSON-RPC response.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.a2aproject.sdk.spec.A2AError
    Gets the error object.
    Gets the request/response correlation identifier.
    Gets the JSON-RPC version for this message.
    Gets the result value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 org.a2aproject.sdk.spec.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, org.a2aproject.sdk.spec.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 org.a2aproject.sdk.spec.A2AError getError()
      Gets the error object.
      Returns:
      the error if any