类 JSONRPCResponse
java.lang.Object
io.github.a2ap.core.jsonrpc.JSONRPCResponse
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.
-
构造器概要
构造器构造器说明Default constructorConstructor with idJSONRPCResponse(String id, JSONRPCError error) Constructor with id and errorJSONRPCResponse(String id, Object result) Constructor with id and result -
方法概要
修饰符和类型方法说明booleangetError()Returns the error object.getId()Returns the request identifier.Returns the JSON-RPC version.Returns the result of the method invocation.inthashCode()voidsetError(JSONRPCError error) Sets the error object.voidSets the request identifier.voidSets the result of the method invocation.toString()
-
构造器详细资料
-
JSONRPCResponse
public JSONRPCResponse()Default constructor -
JSONRPCResponse
Constructor with id- 参数:
id- The request identifier
-
JSONRPCResponse
Constructor with id and result- 参数:
id- The request identifierresult- The result of the method invocation
-
JSONRPCResponse
Constructor with id and error- 参数:
id- The request identifiererror- The error object
-
-
方法详细资料
-
getJsonrpc
Returns the JSON-RPC version.- 返回:
- The JSON-RPC version
-
getResult
Returns the result of the method invocation.- 返回:
- The result
-
setResult
Sets the result of the method invocation.- 参数:
result- The result to set
-
getError
Returns the error object.- 返回:
- The error
-
setError
Sets the error object.- 参数:
error- The error to set
-
getId
Returns the request identifier.- 返回:
- The id
-
setId
Sets the request identifier.- 参数:
id- The id to set
-
equals
-
hashCode
public int hashCode() -
toString
-