Class Message


  • public class Message
    extends Object

    Simplifies the interpretation of messages sent by Carabiner by converting them from their Extensible Data Notation format to more familiar Java structures. Each message consists of a type symbol, optionally followed by a map of keywords and values. Constructing a Message object provides easy access to those values, with the symbol and keywords replaced by ordinary interned Java String instances.

    For example, if instantiated with the string "status { :peers 0 :bpm 120.000000 :start 73743731220 :beat 597.737570 }", a Message instance would have a messageType of "status", and its details would be a Map with keys "peers" (holding the Long value 0), "bpm" (holding the Double value 120.0), "start" (holding the Long value 73743731220), and "beat" (holding the Double value 597.737570).

    An instance constructed with the string "bad-beat" would have a messageType of "bad-beat" and a null details.

    Once constructed, Message objects are immutable data holders.

    Created by James Elliott on 2020-01-19.

    • Field Detail

      • messageType

        public final String messageType
        Identifies the type of the message that was received, which was the symbol that the message started with. This value is interned, so message types can be compared for equality by object identity.
      • details

        public final Map<String,​Object> details
        Holds the details sent after the message type, if any. Will be null if there were no details. Keys in the map are interned strings, so they can be compared for equality by object identity.
    • Constructor Detail

      • Message

        public Message​(String response)
        Construct an instance given an edn response line you have received from Carabiner.
        Parameters:
        response - the full text of a line that Carabiner has sent you