Package com.helger.commons.serialize
Class SerializationHelper
- java.lang.Object
-
- com.helger.commons.serialize.SerializationHelper
-
@Immutable public final class SerializationHelper extends Object
Global serialization helper method.- Since:
- 8.5.5
- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TgetDeserializedObject(byte[] aData)Convert the passed byte array to an object using deserialization.static byte[]getSerializedByteArray(Serializable aData)Convert the passed Serializable object to a serialized byte array.
-
-
-
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 benull.- Returns:
- A non-
nullbyte 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 benull.- Returns:
- The deserialized object. Never
null. - Throws:
IllegalStateException- If deserialization failed
-
-