Class Message

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Message decode​(byte[] bytes)
      Decodes a message from its bytes
      boolean equals​(java.lang.Object obj)  
      boolean getBooleanProperty​(java.lang.String key)
      Get a boolean property from the payload
      boolean getBooleanProperty​(java.lang.String key, boolean defaultValue)
      Get a boolean property from the payload
      java.lang.String getProperty​(java.lang.String key)
      Get a String property from the payload
      java.lang.String getProperty​(java.lang.String key, java.lang.String defaultValue)
      Get a String property from the payload
      java.lang.String getSessionId()  
      int hashCode()  
      java.util.stream.Stream<java.lang.String> keys()  
      static Message replyTo​(Message message, java.util.Map<java.lang.String,​java.lang.String> payload)
      Creates a reply to a message using the thread id and session id from the original but with the provided payload
      byte[] serialize()  
      byte[] serialize​(java.lang.String sessionId)
      Creates bytes for this message using the session id
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • keys

        public java.util.stream.Stream<java.lang.String> keys()
        Returns:
        the keys stored in this message
      • getProperty

        public java.lang.String getProperty​(java.lang.String key)
        Get a String property from the payload
        Parameters:
        key - the key to fetch
        Returns:
        the value
      • getProperty

        public java.lang.String getProperty​(java.lang.String key,
                                            java.lang.String defaultValue)
        Get a String property from the payload
        Parameters:
        key - the key to fetch
        defaultValue - default value to use when no value is present
        Returns:
        the value
      • getBooleanProperty

        public boolean getBooleanProperty​(java.lang.String key)
        Get a boolean property from the payload
        Parameters:
        key - the key to fetch
        Returns:
        the value
      • getBooleanProperty

        public boolean getBooleanProperty​(java.lang.String key,
                                          boolean defaultValue)
        Get a boolean property from the payload
        Parameters:
        key - the key to fetch
        defaultValue - the value to use if not value is present
        Returns:
        the value
      • getSessionId

        public java.lang.String getSessionId()
        Returns:
        the remote session id for this message, only valid for messages not created locally
      • serialize

        public byte[] serialize()
        Returns:
        the bytes using the message session id
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • serialize

        public byte[] serialize​(java.lang.String sessionId)
        Creates bytes for this message using the session id
        Parameters:
        sessionId -
        Returns:
        the bytes using the supplied message id
      • replyTo

        public static Message replyTo​(Message message,
                                      java.util.Map<java.lang.String,​java.lang.String> payload)
        Creates a reply to a message using the thread id and session id from the original but with the provided payload
        Parameters:
        message - the reply message to inherit from
        payload - the new payload
        Returns:
        the message
      • decode

        public static Message decode​(byte[] bytes)
        Decodes a message from its bytes
        Parameters:
        bytes - the bytes to decode
        Returns:
        the message or null if decoding failed
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object