Class ProtobufSerializer

java.lang.Object
org.drasyl.node.handler.serialization.ProtobufSerializer
All Implemented Interfaces:
Serializer

public class ProtobufSerializer extends Object
This Serializer (de)serializes Message objects.
  • Constructor Details

    • ProtobufSerializer

      public ProtobufSerializer()
  • Method Details

    • matchedToByArray

      protected byte[] matchedToByArray(com.google.protobuf.Message o)
    • matchedFromByteArray

      protected com.google.protobuf.Message matchedFromByteArray(byte[] bytes, Class<com.google.protobuf.Message> type) throws IOException
      Throws:
      IOException
    • toByteArray

      public byte[] toByteArray(Object o) throws IOException
      Description copied from interface: Serializer
      Serializes the given object into an array of bytes
      Specified by:
      toByteArray in interface Serializer
      Throws:
      IOException - if deserialization to byte array fails
    • fromByteArray

      public <T> T fromByteArray(byte[] bytes, Class<T> type) throws IOException
      Description copied from interface: Serializer
      Produces an object of type T from an array of bytes.
      Specified by:
      fromByteArray in interface Serializer
      Throws:
      IOException - if serialization to byte array fails