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 Details

    • UUIDSerializer

      public UUIDSerializer()
      Constructs a new UUIDSerializer.
  • Method Details

    • deserialize

      public UUID deserialize(io.netty.buffer.ByteBuf in, NodeStore store)
      Reads a UUID from the buffer by consuming 16 bytes (two longs).
      Specified by:
      deserialize in interface BabelNetworkSerializer<UUID>
      Parameters:
      in - the source buffer
      store - the node store context for resolving node components
      Returns:
      the decoded UUID
    • serialize

      public void serialize(UUID object, io.netty.buffer.ByteBuf out, NodeStore store)
      Description copied from interface: BabelNetworkSerializer
      Encodes object and appends the resulting bytes to out.
      Specified by:
      serialize in interface BabelNetworkSerializer<UUID>
      Parameters:
      object - the object to serialize
      out - the destination buffer
      store - the node store context for resolving node components
    • getObjectClass

      public Class<UUID> getObjectClass()
      Returns UUID.class, which is the type key used by SerializerRegistry to locate this serializer when encoding or decoding UUID fields in generated message serializers.
      Specified by:
      getObjectClass in interface BabelNetworkSerializer<UUID>
      Returns:
      UUID.class