Class UUIDSerializer
java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.serializers.UUIDSerializer
- All Implemented Interfaces:
BabelNetworkSerializer<UUID>
@AutoService(BabelNetworkSerializer.class)
public final class UUIDSerializer
extends Object
implements BabelNetworkSerializer<UUID>
Binary serializer for
UUID values, encoding each instance as two consecutive
8-byte big-endian longs (most-significant bits followed by least-significant bits),
for a total wire size of 16 bytes.
Registered as a BabelNetworkSerializer service provider and discovered at runtime by
the SerializerRegistry, making it available for use as a field type inside records
annotated with BabelIPMessage.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(io.netty.buffer.ByteBuf in, NodeStore store) Reads aUUIDfrom the buffer by consuming 16 bytes (two longs).ReturnsUUID.class, which is the type key used bySerializerRegistryto locate this serializer when encoding or decoding UUID fields in generated message serializers.voidEncodesobjectand appends the resulting bytes toout.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BabelNetworkSerializer
getEstimateSize, getEstimateSizeModifier and TypeMethodDescriptiondefault intgetEstimateSize(UUID object) Returns an estimated size in bytes for the given object.default intgetEstimateSize(UUID object, @Nullable NodeStore store) Returns a size estimate to fit the entire object in aByteBufwithout needing resizes.
-
Constructor Details
-
UUIDSerializer
public UUIDSerializer()Constructs a newUUIDSerializer.
-
-
Method Details
-
deserialize
Reads aUUIDfrom the buffer by consuming 16 bytes (two longs).- Specified by:
deserializein interfaceBabelNetworkSerializer<UUID>- Parameters:
in- the source bufferstore- the node store context for resolving node components- Returns:
- the decoded UUID
-
serialize
Description copied from interface:BabelNetworkSerializerEncodesobjectand appends the resulting bytes toout.- Specified by:
serializein interfaceBabelNetworkSerializer<UUID>- Parameters:
object- the object to serializeout- the destination bufferstore- the node store context for resolving node components
-
getObjectClass
ReturnsUUID.class, which is the type key used bySerializerRegistryto locate this serializer when encoding or decoding UUID fields in generated message serializers.- Specified by:
getObjectClassin interfaceBabelNetworkSerializer<UUID>- Returns:
UUID.class
-