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 Object implements Serializer<T>
A serializer decorator, that performs some extra checks to ensure that a user-supplied serializer adheres toSerializer
contract. These are required in Java code that interacts with native code and accepts user-implemented serializers.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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 Detail
-
from
public static <T> CheckingSerializerDecorator<T> from(Serializer<T> serializer)
Creates a checking serializer decorator. Will not decorate itself.- Parameters:
serializer
- a serializer to decorate
-
toBytes
public byte[] toBytes(T value)
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
public T fromBytes(byte[] serializedValue)
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
-
-