Package com.helger.base.serialize
Class SerializationHelper
java.lang.Object
com.helger.base.serialize.SerializationHelper
Global serialization helper method.
- Since:
- 8.5.5
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NonNull TgetDeserializedObject(byte @NonNull [] aData) Deprecated.static <T> @NonNull TgetDeserializedObject(byte @NonNull [] aData, @Nullable ObjectInputFilter aFilter) Convert the passed byte array to an object using deserialization.static byte @NonNull []getSerializedByteArray(@NonNull Serializable aData) Convert the passed Serializable object to a serialized byte array.
-
Method Details
-
getSerializedByteArray
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
public static <T> @NonNull T getDeserializedObject(byte @NonNull [] aData, @Nullable ObjectInputFilter aFilter) 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.aFilter- An optionalObjectInputFilterto restrict deserialization. May benull.- Returns:
- The deserialized object. Never
null. - Throws:
IllegalStateException- If deserialization failed- Since:
- 12.2.1
-
getDeserializedObject
@Deprecated(since="12.2.1", forRemoval=false) public static <T> @NonNull T getDeserializedObject(byte @NonNull [] aData) Deprecated.UsegetDeserializedObject(byte[], ObjectInputFilter)with an appropriate filter instead.Convert the passed byte array to an object using deserialization. This method does not apply anyObjectInputFilterand should only be used with trusted data.- 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
-
getDeserializedObject(byte[], ObjectInputFilter)with an appropriate filter instead.