Interface JsonMessage

All Known Subinterfaces:
TelestionConfiguration
All Known Implementing Classes:
DecodedMessage, GenericConfiguration

public interface JsonMessage
The base class for all messages which are automatically encoded with the JsonMessageCodec.
All subclasses have to be valid json classes. This means that they could be encoded by JsonCodec which is backed by JacksonCodec.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static io.vertx.core.spi.json.JsonCodec
     
    static org.slf4j.Logger
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Returns the simple class name of the subclass.
    static <T extends JsonMessage>
    T
    from​(Object json, Class<T> type)
    Creates a message from the given json representation.
    static <T extends JsonMessage>
    T
    from​(String json, Class<T> type)
    Creates a message from the given json representation.
    default io.vertx.core.json.JsonObject
    Returns the Json-representation of the message.
    static <T extends JsonMessage>
    boolean
    on​(Class<T> clazz, io.vertx.core.eventbus.Message<?> msg, io.vertx.core.Handler<T> handler)
    This method decodes a JsonMessage from the event bus.
    Returns whether decoding was successful or not.
    static <T extends JsonMessage>
    boolean
    on​(Class<T> clazz, Object msgBody, io.vertx.core.Handler<T> handler)
    This method decodes a JsonMessage from the event bus.
    Returns whether decoding was successful or not.
  • Field Details

    • JSON_CODEC

      static final io.vertx.core.spi.json.JsonCodec JSON_CODEC
    • logger

      static final org.slf4j.Logger logger
  • Method Details

    • on

      static <T extends JsonMessage> boolean on(Class<T> clazz, Object msgBody, io.vertx.core.Handler<T> handler)
      This method decodes a JsonMessage from the event bus.
      Returns whether decoding was successful or not.
      Type Parameters:
      T - Generic type for the Handler
      Parameters:
      clazz - Class of the message-object
      msgBody - msg-body of the sent message
      handler - handler for the message
      Returns:
      whether decoding was successful
    • on

      static <T extends JsonMessage> boolean on(Class<T> clazz, io.vertx.core.eventbus.Message<?> msg, io.vertx.core.Handler<T> handler)
      This method decodes a JsonMessage from the event bus.
      Returns whether decoding was successful or not.
      Type Parameters:
      T - type of the Message
      Parameters:
      clazz - Class of the message-object
      msg - sent message
      handler - handler for the message
      Returns:
      whether decoding was successful
    • from

      static <T extends JsonMessage> T from(String json, Class<T> type)
      Creates a message from the given json representation.
      Type Parameters:
      T - type of the Message
      Parameters:
      json - source
      type - class of the message
      Returns:
      decoded message object
    • from

      static <T extends JsonMessage> T from(Object json, Class<T> type)
      Creates a message from the given json representation.
      Type Parameters:
      T - type of the Message
      Parameters:
      json - source which must be a String
      type - class of the message
      Returns:
      decoded message object
    • className

      default String className()
      Returns the simple class name of the subclass.
      Returns:
      simple class name of subclass
    • json

      default io.vertx.core.json.JsonObject json()
      Returns the Json-representation of the message.
      Returns:
      json representation of message