Package co.arago.hiro.client.websocket
Class ActionWebSocket.ResultParams
- java.lang.Object
-
- co.arago.hiro.client.websocket.ActionWebSocket.ResultParams
-
- Enclosing class:
- ActionWebSocket
public static class ActionWebSocket.ResultParams extends java.lang.ObjectThis creates a useful payload for theActionHandlerResult.If no code is set, 200 or 204 will be assumed depending on whether data is present or not.
If no message is set, a standard message will be generated depending on whether data is present or not.
Without data:
{ "code": code, "message": message }or with data:
{ "code": code, "message": message, "data": data }
-
-
Constructor Summary
Constructors Constructor Description ResultParams()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.IntegergetCode()Get the code.java.lang.StringgetData()Get datajava.lang.StringgetMessage()Get the message.ActionWebSocket.ResultParamssetCode(java.lang.Integer code)Sets the status code.ActionWebSocket.ResultParamssetData(java.lang.String data)Sets the data as StringActionWebSocket.ResultParamssetData(java.util.Map<java.lang.String,java.lang.Object> result)Sets the data string from a map.ActionWebSocket.ResultParamssetMessage(java.lang.String message)Sets the status messagejava.lang.StringtoResultPayload()Transform message to message string.
-
-
-
Method Detail
-
setCode
public ActionWebSocket.ResultParams setCode(java.lang.Integer code)
Sets the status code.- Parameters:
code- The status code.- Returns:
- this
-
setMessage
public ActionWebSocket.ResultParams setMessage(java.lang.String message)
Sets the status message- Parameters:
message- The status message- Returns:
- this
-
setData
public ActionWebSocket.ResultParams setData(java.lang.String data)
Sets the data as String- Parameters:
data- The data to set- Returns:
- this
-
setData
public ActionWebSocket.ResultParams setData(java.util.Map<java.lang.String,java.lang.Object> result) throws com.fasterxml.jackson.core.JsonProcessingException
Sets the data string from a map.- Parameters:
result- The data to set- Returns:
- this
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- If the map cannot be transformed to a String.
-
getCode
public java.lang.Integer getCode()
Get the code.- Returns:
- The code or 200 when code == null and data != null or 204 when both are null.
-
getMessage
public java.lang.String getMessage()
Get the message.- Returns:
- The message or a standard message when message == null.
-
getData
public java.lang.String getData()
Get data- Returns:
- The data. Can be null.
-
toResultPayload
public java.lang.String toResultPayload()
Transform message to message string. Skipdataif it is null.- Returns:
- The string representation of this message.
-
-