Class SerializationHelper


  • @Immutable
    public final class SerializationHelper
    extends Object
    Global serialization helper method.
    Since:
    8.5.5
    Author:
    Philip Helger
    • Method Detail

      • getSerializedByteArray

        @Nonnull
        public static byte[] getSerializedByteArray​(@Nonnull
                                                    Serializable aData)
        Convert the passed Serializable object to a serialized byte array.
        Parameters:
        aData - Source object. May not be null.
        Returns:
        A non-null byte array.
        Throws:
        IllegalStateException - If serialization failed
      • getDeserializedObject

        @Nonnull
        public static <T> T getDeserializedObject​(@Nonnull
                                                  byte[] aData)
        Convert the passed byte array to an object using deserialization.
        Type Parameters:
        T - The type of the deserialized object
        Parameters:
        aData - The source serialized byte array. Must contain a single object only. May not be null.
        Returns:
        The deserialized object. Never null.
        Throws:
        IllegalStateException - If deserialization failed