Package io.micronaut.rabbitmq.serdes
Class JavaLangRabbitMessageSerDes
- java.lang.Object
-
- io.micronaut.rabbitmq.serdes.JavaLangRabbitMessageSerDes
-
- All Implemented Interfaces:
io.micronaut.core.order.Ordered,RabbitMessageSerDes<java.lang.Object>
@Singleton public class JavaLangRabbitMessageSerDes extends java.lang.Object implements RabbitMessageSerDes<java.lang.Object>
Serializes and deserializes standard Java types.- Since:
- 1.1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<RabbitMessageSerDes>javaSerDesstatic java.lang.IntegerORDERThe order of this serDes.
-
Constructor Summary
Constructors Constructor Description JavaLangRabbitMessageSerDes()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectdeserialize(RabbitConsumerState messageState, io.micronaut.core.type.Argument<java.lang.Object> argument)Deserializes the message into the requested type.protected RabbitMessageSerDesfindSerDes(io.micronaut.core.type.Argument<?> type)Finds the correct serDes based on the type.protected RabbitMessageSerDes<java.lang.Boolean>getBooleanSerDes()protected RabbitMessageSerDes<byte[]>getByteArraySerDes()protected RabbitMessageSerDes<java.nio.ByteBuffer>getByteBufferSerDes()protected RabbitMessageSerDes<java.lang.Double>getDoubleSerDes()protected RabbitMessageSerDes<java.lang.Float>getFloatSerDes()protected RabbitMessageSerDes<java.lang.Integer>getIntegerSerDes()protected RabbitMessageSerDes<java.lang.Long>getLongSerDes()intgetOrder()protected RabbitMessageSerDes<java.lang.Short>getShortSerDes()protected RabbitMessageSerDes<java.lang.String>getStringSerDes()protected RabbitMessageSerDes<java.util.UUID>getUUIDSerDes()byte[]serialize(java.lang.Object data, MutableBasicProperties properties)Serializes the data into a byte[] to be published to RabbitMQ.booleansupports(io.micronaut.core.type.Argument<java.lang.Object> argument)Determines if this serdes supports the given type.
-
-
-
Field Detail
-
ORDER
public static final java.lang.Integer ORDER
The order of this serDes.
-
javaSerDes
protected final java.util.List<RabbitMessageSerDes> javaSerDes
-
-
Method Detail
-
serialize
public byte[] serialize(@Nullable java.lang.Object data, MutableBasicProperties properties)Description copied from interface:RabbitMessageSerDesSerializes the data into a byte[] to be published to RabbitMQ.- Specified by:
serializein interfaceRabbitMessageSerDes<java.lang.Object>- Parameters:
data- The data to serializeproperties- The properties of the message- Returns:
- The message body
-
deserialize
public java.lang.Object deserialize(RabbitConsumerState messageState, io.micronaut.core.type.Argument<java.lang.Object> argument)
Description copied from interface:RabbitMessageSerDesDeserializes the message into the requested type.- Specified by:
deserializein interfaceRabbitMessageSerDes<java.lang.Object>- Parameters:
messageState- The message to deserializeargument- The type to be returned- Returns:
- The deserialized body
-
supports
public boolean supports(io.micronaut.core.type.Argument<java.lang.Object> argument)
Description copied from interface:RabbitMessageSerDesDetermines if this serdes supports the given type.- Specified by:
supportsin interfaceRabbitMessageSerDes<java.lang.Object>- Parameters:
argument- The type- Returns:
- True if the type is supported
-
getOrder
public int getOrder()
- Specified by:
getOrderin interfaceio.micronaut.core.order.Ordered
-
findSerDes
@Nullable protected RabbitMessageSerDes findSerDes(io.micronaut.core.type.Argument<?> type)
Finds the correct serDes based on the type.- Parameters:
type- The java type- Returns:
- The serdes, or null if none can be found
-
getStringSerDes
@NonNull protected RabbitMessageSerDes<java.lang.String> getStringSerDes()
- Returns:
- The serDes that handles
String
-
getShortSerDes
@NonNull protected RabbitMessageSerDes<java.lang.Short> getShortSerDes()
- Returns:
- The serDes that handles
Short
-
getIntegerSerDes
@NonNull protected RabbitMessageSerDes<java.lang.Integer> getIntegerSerDes()
- Returns:
- The serDes that handles
Integer
-
getLongSerDes
@NonNull protected RabbitMessageSerDes<java.lang.Long> getLongSerDes()
- Returns:
- The serDes that handles
Long
-
getFloatSerDes
@NonNull protected RabbitMessageSerDes<java.lang.Float> getFloatSerDes()
- Returns:
- The serDes that handles
Float
-
getDoubleSerDes
@NonNull protected RabbitMessageSerDes<java.lang.Double> getDoubleSerDes()
- Returns:
- The serDes that handles
Double
-
getByteArraySerDes
@NonNull protected RabbitMessageSerDes<byte[]> getByteArraySerDes()
- Returns:
- The serDes that handles byte[]
-
getByteBufferSerDes
@NonNull protected RabbitMessageSerDes<java.nio.ByteBuffer> getByteBufferSerDes()
- Returns:
- The serDes that handles
ByteBuffer
-
getUUIDSerDes
@NonNull protected RabbitMessageSerDes<java.util.UUID> getUUIDSerDes()
- Returns:
- The serDes that handles
UUID
-
getBooleanSerDes
@NonNull protected RabbitMessageSerDes<java.lang.Boolean> getBooleanSerDes()
- Returns:
- The serDes that handles
UUID
-
-