Class 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

      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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