Package network

Interface ISerializer<T>

Type Parameters:
T - The type of the object which this class serializes

public interface ISerializer<T>
Represents a serializer/deserializer that writes/reads objects to/from a byte buffer
Author:
pfouto
  • Method Summary

    Modifier and Type Method Description
    T deserialize​(io.netty.buffer.ByteBuf in)
    Deserializes an object from a byte buffer and returns it.
    void serialize​(T t, io.netty.buffer.ByteBuf out)
    Serializes the received object into the received byte buffer.
    int serializedSize​(T t)
    Calculates the serialized size of a given object2
  • Method Details

    • serialize

      void serialize​(T t, io.netty.buffer.ByteBuf out)
      Serializes the received object into the received byte buffer.
      Parameters:
      t - The object to serialize
      out - The byte buffer to which the object will the written
    • deserialize

      T deserialize​(io.netty.buffer.ByteBuf in) throws UnknownHostException
      Deserializes an object from a byte buffer and returns it.
      Parameters:
      in - The byte buffer which contains the object to be deserialized
      Returns:
      The deserialized object
      Throws:
      UnknownHostException - if the message to be deserialized contains a host that cannot be deserialized. Should never be thrown (visible for testing).
    • serializedSize

      int serializedSize​(T t)
      Calculates the serialized size of a given object2
      Parameters:
      t - The object whose size is to be calculated
      Returns:
      The size of the object when serialized