Package org.drasyl.serialization
Interface Serializer
-
- All Known Implementing Classes:
BooleanSerializer
,ByteArraySerializer
,ByteSerializer
,CharacterSerializer
,DisabledSerializer
,DoubleSerializer
,FloatSerializer
,IntegerSerializer
,JacksonJsonSerializer
,JavaSerializer
,LongSerializer
,NullSerializer
,ProtobufSerializer
,ShortSerializer
,StringSerializer
public interface Serializer
A Serializer represents a bimap between an object and an array of bytes representing that object.Make sure that your implementation implements the standard constructor!
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T> T
fromByteArray(byte[] bytes, Class<T> type)
Produces an object of typeT
from an array of bytes.default Object
fromByteArray(byte[] bytes, String typeName)
byte[]
toByteArray(Object o)
Serializes the given object into an array of bytes
-
-
-
Method Detail
-
toByteArray
byte[] toByteArray(Object o) throws IOException
Serializes the given object into an array of bytes- Throws:
IOException
- if deserialization from byte array fails
-
fromByteArray
<T> T fromByteArray(byte[] bytes, Class<T> type) throws IOException
Produces an object of typeT
from an array of bytes.- Throws:
IOException
- if serialization to byte array fails
-
fromByteArray
default Object fromByteArray(byte[] bytes, String typeName) throws IOException
- Throws:
IOException
-
-