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 StringcontentAsJsonString()booleanequals(Object obj)This method returnstrueif the argument is aResponseand all properties are equal, otherwise returnsfalse.Optional<Error>error()Getter for error field.inthashCode()This method is implemented usingObjects.hash().Id<?>id()Getter for id field.booleanisSuccessful()Whether the request that generated thisResponsewas successful.booleanisUnsuccessful()Whether thisResponsecontains an error.Stringjsonrpc()Getter for jsonrpc field.Optional<com.google.gson.JsonElement>result()Getter for result field.StringtoString()
-
-
-
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
Optionalis empty theResponseis considered to be an error response.- Returns:
- The result of this
Response
-
error
public Optional<Error> error()
Getter for error field.If the
Optionalis not empty theResponseis considered to be an error response.- Returns:
- The error of this
Response
-
isSuccessful
public boolean isSuccessful()
Whether the request that generated thisResponsewas successful.- Returns:
trueifresultfield is present elsefalse
-
isUnsuccessful
public boolean isUnsuccessful()
Whether thisResponsecontains an error.- Returns:
trueiferrorfield is present elsefalse
-
hashCode
public int hashCode()
This method is implemented usingObjects.hash().
-
equals
public boolean equals(Object obj)
This method returnstrueif the argument is aResponseand all properties are equal, otherwise returnsfalse.
-
toString
public String toString()
-
-