Package eliasstar.jsonrpc.objects
Class Response
- java.lang.Object
-
- eliasstar.jsonrpc.objects.Response
-
public final class Response extends Object
Represents a JSON-RPC response.- Since:
- 0.1.0
- Author:
- Elias*
- See Also:
- JSON-RPC Specification
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
contentAsJsonString()
boolean
equals(Object obj)
This method returnstrue
if the argument is aResponse
and all properties are equal, otherwise returnsfalse
.Optional<Error>
error()
Getter for error field.int
hashCode()
This method is implemented usingObjects.hash()
.Id<?>
id()
Getter for id field.boolean
isSuccessful()
Whether the request that generated thisResponse
was successful.boolean
isUnsuccessful()
Whether thisResponse
contains an error.String
jsonrpc()
Getter for jsonrpc field.Optional<com.google.gson.JsonElement>
result()
Getter for result field.String
toString()
-
-
-
Method Detail
-
jsonrpc
public String jsonrpc()
Getter for jsonrpc field.It is always
"2.0"
.- Returns:
- The version of the JSON-RPC protocol
-
result
public Optional<com.google.gson.JsonElement> result()
Getter for result field.If the
Optional
is empty theResponse
is considered to be an error response.- Returns:
- The result of this
Response
-
error
public Optional<Error> error()
Getter for error field.If the
Optional
is not empty theResponse
is considered to be an error response.- Returns:
- The error of this
Response
-
isSuccessful
public boolean isSuccessful()
Whether the request that generated thisResponse
was successful.- Returns:
true
ifresult
field is present elsefalse
-
isUnsuccessful
public boolean isUnsuccessful()
Whether thisResponse
contains an error.- Returns:
true
iferror
field is present elsefalse
-
hashCode
public int hashCode()
This method is implemented usingObjects.hash()
.
-
equals
public boolean equals(Object obj)
This method returnstrue
if the argument is aResponse
and all properties are equal, otherwise returnsfalse
.
-
toString
public String toString()
-
-