Interface Serializer<T>
-
- Type Parameters:
T- a type of serializable object
- All Known Implementing Classes:
CheckingSerializerDecorator
public interface Serializer<T>Converts Java objects into a binary representation in some format, and vice versa.Implementations must ensure that for any object o,
toBytes(Object)produces such an array, that being passed tofromBytes(byte[]), is converted to another object o2, that is equal to the original object o.This interface is designed to be primarily used by storage proxies and proof validators.
- See Also:
StandardSerializers
-
-
Method Detail
-
toBytes
byte[] toBytes(T value)
Serializes a given value into a byte array.- Parameters:
value- a value to serialize, must not be null- Returns:
- a byte array containing a serialized value
- Throws:
NullPointerException- if value is null
-
fromBytes
T fromBytes(byte[] serializedValue)
De-serializes a value from a given byte array.- Parameters:
serializedValue- an array containing a serialized value of type T, must not be null- Returns:
- a value
- Throws:
NullPointerException- if the array is nullIllegalArgumentException- if the array cannot be decoded into a value of type T (e.g., contains 2 bytes when 4 are expected)
-
-