Class 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 to Serializer contract. These are required in Java code that interacts with native code and accepts user-implemented serializers.
    • 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 interface Serializer<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 interface Serializer<T>
        Parameters:
        serializedValue - an array containing a serialized value of type T, must not be null
        Returns:
        a value