public class SerializableUtils
extends java.lang.Object
Constructor and Description |
---|
SerializableUtils() |
Modifier and Type | Method and Description |
---|---|
static <T extends java.io.Serializable> |
clone(T value) |
static java.lang.Object |
deserializeFromByteArray(byte[] encodedValue,
java.lang.String description)
Deserializes an object from the given array of bytes, e.g., as serialized using
serializeToByteArray(java.io.Serializable) , and returns it. |
static Coder<?> |
ensureSerializable(Coder<?> coder)
Serializes a Coder and verifies that it can be correctly deserialized.
|
static <T extends java.io.Serializable> |
ensureSerializable(T value) |
static <T> T |
ensureSerializableByCoder(Coder<T> coder,
T value,
java.lang.String errorContext)
Serializes an arbitrary T with the given
Coder<T> and verifies that it can be correctly
deserialized. |
static <T extends java.io.Serializable> |
ensureSerializableRoundTrip(T value) |
static byte[] |
serializeToByteArray(java.io.Serializable value)
Serializes the argument into an array of bytes, and returns it.
|
public static byte[] serializeToByteArray(java.io.Serializable value)
java.lang.IllegalArgumentException
- if there are errors when serializingpublic static java.lang.Object deserializeFromByteArray(byte[] encodedValue, java.lang.String description)
serializeToByteArray(java.io.Serializable)
, and returns it.java.lang.IllegalArgumentException
- if there are errors when deserializing, using the provided
description to identify what was being deserializedpublic static <T extends java.io.Serializable> T ensureSerializableRoundTrip(T value)
public static <T extends java.io.Serializable> T ensureSerializable(T value)
public static <T extends java.io.Serializable> T clone(T value)
public static Coder<?> ensureSerializable(Coder<?> coder)
Throws a RuntimeException if serialized Coder cannot be deserialized, or if the deserialized instance is not equal to the original.
public static <T> T ensureSerializableByCoder(Coder<T> coder, T value, java.lang.String errorContext)
Coder<T>
and verifies that it can be correctly
deserialized.