Class ActionWebSocket.ResultParams

  • Enclosing class:
    ActionWebSocket

    public static class ActionWebSocket.ResultParams
    extends java.lang.Object
    This creates a useful payload for the ActionHandlerResult.

    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 Detail

      • ResultParams

        public ResultParams()
    • 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. Skip data if it is null.
        Returns:
        The string representation of this message.