Class ChannelInfoSerializer

java.lang.Object
pt.unl.fct.di.novasys.babel2.protocols.discovery.serializers.ChannelInfoSerializer
All Implemented Interfaces:
BabelNetworkSerializer<ChannelInfo>

@AutoService(BabelNetworkSerializer.class) public class ChannelInfoSerializer extends Object implements BabelNetworkSerializer<ChannelInfo>
Network serializer for ChannelInfo records.
  • Constructor Details

    • ChannelInfoSerializer

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

    • deserialize

      public ChannelInfo deserialize(io.netty.buffer.ByteBuf in, NodeStore store)
      Description copied from interface: BabelNetworkSerializer
      Reads an instance of T from the supplied buffer. The buffer's reader index must be positioned at the first byte of the encoded object. Upon return the reader index is advanced past all bytes consumed.
      Specified by:
      deserialize in interface BabelNetworkSerializer<ChannelInfo>
      Parameters:
      in - the source buffer
      store - the node store context for resolving node components
      Returns:
      the deserialized object
    • serialize

      public void serialize(ChannelInfo 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<ChannelInfo>
      Parameters:
      object - the object to serialize
      out - the destination buffer
      store - the node store context for resolving node components
    • getObjectClass

      public Class<ChannelInfo> getObjectClass()
      Description copied from interface: BabelNetworkSerializer
      Returns the class of objects handled by this serializer, used for registry lookup.
      Specified by:
      getObjectClass in interface BabelNetworkSerializer<ChannelInfo>
      Returns:
      the handled class
    • getEstimateSize

      public int getEstimateSize(ChannelInfo object, NodeStore store)
      Description copied from interface: BabelNetworkSerializer
      Returns a size estimate to fit the entire object in a ByteBuf without needing resizes. The default implementation returns 0. For maximum serialization performance, override this method.
      Specified by:
      getEstimateSize in interface BabelNetworkSerializer<ChannelInfo>
      Parameters:
      object - the object to estimate the size
      store - the node store for node lookups during size estimation, or null
      Returns:
      the expected size in bytes to fit the object in a ByteBuf