类 JSONRPCResponse

java.lang.Object
io.github.a2ap.core.jsonrpc.JSONRPCResponse

public class JSONRPCResponse extends Object
Represents a JSON-RPC 2.0 response object as defined in the JSON-RPC specification. This class encapsulates the response structure for JSON-RPC method invocations, containing either a successful result or an error object. The response always includes the JSON-RPC version ("2.0") and the request identifier for correlation. Key characteristics: - The result and error fields are mutually exclusive - only one can be present - For successful method invocations, the result field contains the return value - For failed method invocations, the error field contains detailed error information - The id field matches the corresponding request identifier for proper correlation In the A2A protocol context, successful results can be various types: - Message objects for immediate responses - Task objects for asynchronous operations - TaskStatusUpdateEvent objects for status changes - TaskArtifactUpdateEvent objects for artifact updates This class enforces the mutual exclusivity of result and error fields through its setter methods to maintain JSON-RPC specification compliance.
  • 构造器详细资料

    • JSONRPCResponse

      public JSONRPCResponse()
      Default constructor
    • JSONRPCResponse

      public JSONRPCResponse(String id)
      Constructor with id
      参数:
      id - The request identifier
    • JSONRPCResponse

      public JSONRPCResponse(String id, Object result)
      Constructor with id and result
      参数:
      id - The request identifier
      result - The result of the method invocation
    • JSONRPCResponse

      public JSONRPCResponse(String id, JSONRPCError error)
      Constructor with id and error
      参数:
      id - The request identifier
      error - The error object
  • 方法详细资料

    • getJsonrpc

      public String getJsonrpc()
      Returns the JSON-RPC version.
      返回:
      The JSON-RPC version
    • getResult

      public Object getResult()
      Returns the result of the method invocation.
      返回:
      The result
    • setResult

      public void setResult(Object result)
      Sets the result of the method invocation.
      参数:
      result - The result to set
    • getError

      public JSONRPCError getError()
      Returns the error object.
      返回:
      The error
    • setError

      public void setError(JSONRPCError error)
      Sets the error object.
      参数:
      error - The error to set
    • getId

      public String getId()
      Returns the request identifier.
      返回:
      The id
    • setId

      public void setId(String id)
      Sets the request identifier.
      参数:
      id - The id to set
    • equals

      public boolean equals(Object o)
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object