Package io.micronaut.mqtt.serdes
Class JavaLangMqttPayloadSerDes
java.lang.Object
io.micronaut.mqtt.serdes.JavaLangMqttPayloadSerDes
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,MqttPayloadSerDes<Object>
@Singleton
public class JavaLangMqttPayloadSerDes
extends Object
implements MqttPayloadSerDes<Object>
Serializes and deserializes standard Java types.
- Since:
- 1.1.0
- Author:
- James Kleeh
-
Field Summary
Modifier and TypeFieldDescriptionprotected final List<MqttPayloadSerDes>
static final Integer
The order of this serDes.Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondeserialize
(byte[] payload, io.micronaut.core.type.Argument<Object> argument) Deserializes the message into the requested type.protected @Nullable MqttPayloadSerDes
findSerDes
(io.micronaut.core.type.Argument<?> type) Finds the correct serDes based on the type.protected @NonNull MqttPayloadSerDes<Boolean>
protected @NonNull MqttPayloadSerDes<byte[]>
protected @NonNull MqttPayloadSerDes<ByteBuffer>
protected @NonNull MqttPayloadSerDes<Double>
protected @NonNull MqttPayloadSerDes<Float>
protected @NonNull MqttPayloadSerDes<Integer>
protected @NonNull MqttPayloadSerDes<Long>
int
getOrder()
protected @NonNull MqttPayloadSerDes<Short>
protected @NonNull MqttPayloadSerDes<String>
protected @NonNull MqttPayloadSerDes<UUID>
byte[]
Serializes the data into a byte[] to be published to MQTT.boolean
Determines if this serdes supports the given type.
-
Field Details
-
ORDER
The order of this serDes. -
javaSerDes
-
-
Constructor Details
-
JavaLangMqttPayloadSerDes
public JavaLangMqttPayloadSerDes()Default constructor.
-
-
Method Details
-
serialize
Description copied from interface:MqttPayloadSerDes
Serializes the data into a byte[] to be published to MQTT.- Specified by:
serialize
in interfaceMqttPayloadSerDes<Object>
- Parameters:
data
- The data to serialize- Returns:
- The message body
-
deserialize
Description copied from interface:MqttPayloadSerDes
Deserializes the message into the requested type.- Specified by:
deserialize
in interfaceMqttPayloadSerDes<Object>
- Parameters:
payload
- The message to deserializeargument
- The type to be returned- Returns:
- The deserialized body
-
supports
Description copied from interface:MqttPayloadSerDes
Determines if this serdes supports the given type.- Specified by:
supports
in interfaceMqttPayloadSerDes<Object>
- Parameters:
argument
- The type- Returns:
- True if the type is supported
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceio.micronaut.core.order.Ordered
-
findSerDes
Finds the correct serDes based on the type.- Parameters:
type
- The java type- Returns:
- The serdes, or null if none can be found
-
getStringSerDes
- Returns:
- The serDes that handles
String
-
getShortSerDes
- Returns:
- The serDes that handles
Short
-
getIntegerSerDes
- Returns:
- The serDes that handles
Integer
-
getLongSerDes
- Returns:
- The serDes that handles
Long
-
getFloatSerDes
- Returns:
- The serDes that handles
Float
-
getDoubleSerDes
- Returns:
- The serDes that handles
Double
-
getByteArraySerDes
- Returns:
- The serDes that handles byte[]
-
getByteBufferSerDes
- Returns:
- The serDes that handles
ByteBuffer
-
getUUIDSerDes
- Returns:
- The serDes that handles
UUID
-
getBooleanSerDes
- Returns:
- The serDes that handles
UUID
-