Class ProtobufSerializer
java.lang.Object
org.drasyl.node.handler.serialization.ProtobufSerializer
- All Implemented Interfaces:
Serializer
This Serializer (de)serializes
Message
objects.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
fromByteArray
(byte[] bytes, Class<T> type) Produces an object of typeT
from an array of bytes.protected com.google.protobuf.Message
matchedFromByteArray
(byte[] bytes, Class<com.google.protobuf.Message> type) protected byte[]
matchedToByArray
(com.google.protobuf.Message o) byte[]
Serializes the given object into an array of bytesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.drasyl.node.handler.serialization.Serializer
fromByteArray
-
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
Description copied from interface:Serializer
Serializes the given object into an array of bytes- Specified by:
toByteArray
in interfaceSerializer
- Throws:
IOException
- if deserialization to byte array fails
-
fromByteArray
Description copied from interface:Serializer
Produces an object of typeT
from an array of bytes.- Specified by:
fromByteArray
in interfaceSerializer
- Throws:
IOException
- if serialization to byte array fails
-