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
All subclasses have to be valid json classes. This means that they could be encoded by
JsonCodec
which is backed by JacksonCodec
.-
Field Summary
Modifier and TypeFieldDescriptionstatic io.vertx.core.spi.json.JsonCodec
static org.slf4j.Logger
-
Method Summary
Modifier and TypeMethodDescriptiondefault String
Returns the simple class name of the subclass.static <T extends JsonMessage>
TCreates a message from the given json representation.static <T extends JsonMessage>
TCreates a message from the given json representation.default io.vertx.core.json.JsonObject
json()
Returns the Json-representation of the message.static <T extends JsonMessage>
booleanThis method decodes aJsonMessage
from the event bus.
Returns whether decoding was successful or not.static <T extends JsonMessage>
booleanThis method decodes aJsonMessage
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 aJsonMessage
from the event bus.
Returns whether decoding was successful or not.- Type Parameters:
T
- Generic type for theHandler
- Parameters:
clazz
- Class of the message-objectmsgBody
-msg-body
of the sent messagehandler
- 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 aJsonMessage
from the event bus.
Returns whether decoding was successful or not.- Type Parameters:
T
- type of theMessage
- Parameters:
clazz
- Class of the message-objectmsg
- sent messagehandler
- handler for the message- Returns:
- whether decoding was successful
-
from
Creates a message from the given json representation.- Type Parameters:
T
- type of theMessage
- Parameters:
json
- sourcetype
- class of the message- Returns:
- decoded message object
-
from
Creates a message from the given json representation.- Type Parameters:
T
- type of theMessage
- Parameters:
json
- source which must be a Stringtype
- class of the message- Returns:
- decoded message object
-
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
-