Class CheckingSerializerDecorator<T>
java.lang.Object
com.exonum.binding.common.serialization.CheckingSerializerDecorator<T>
- Type Parameters:
T
- a type of serializable object
- All Implemented Interfaces:
Serializer<T>
public final class CheckingSerializerDecorator<T> extends java.lang.Object implements Serializer<T>
A serializer decorator, that performs some extra checks to ensure that a user-supplied
serializer adheres to
Serializer
contract. These are required in Java code
that interacts with native code and accepts user-implemented serializers.-
Method Summary
Modifier and Type Method Description static <T> CheckingSerializerDecorator<T>
from(Serializer<T> serializer)
Creates a checking serializer decorator.T
fromBytes(byte[] serializedValue)
De-serializes a value from a given byte array.byte[]
toBytes(T value)
Serializes a given value into a byte array.
-
Method Details
-
from
Creates a checking serializer decorator. Will not decorate itself.- Parameters:
serializer
- a serializer to decorate
-
toBytes
Description copied from interface:Serializer
Serializes a given value into a byte array.- Specified by:
toBytes
in interfaceSerializer<T>
- Parameters:
value
- a value to serialize, must not be null- Returns:
- a byte array containing a serialized value
-
fromBytes
Description copied from interface:Serializer
De-serializes a value from a given byte array.- Specified by:
fromBytes
in interfaceSerializer<T>
- Parameters:
serializedValue
- an array containing a serialized value of type T, must not be null- Returns:
- a value
-