@ThreadSafe public final class SerializationUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Serializable |
deserialize(byte[] bytes)
Deserializes a byte array into an object.
|
static Serializable |
deserialize(byte[] bytes,
String errorMessage)
Wrapper around
#deserialize(Object) which throws a runtime exception with the given
message on failure. |
static <S,T extends Serializable> |
makeValuesSerializable(Map<S,Collection<T>> map) |
static String |
parseBenchmarkResult(String result)
Parse the actual JSON result from the benchmark output.
|
static byte[] |
serialize(Object obj)
Serializes an object into a byte array.
|
static byte[] |
serialize(Object obj,
String errorMessage)
Wrapper around
serialize(Object) which throws a runtime exception with the given
message on failure. |
public static byte[] serialize(Object obj) throws IOException
obj
- the object to serializeIOException
- if the serialization failspublic static byte[] serialize(Object obj, String errorMessage)
serialize(Object)
which throws a runtime exception with the given
message on failure.obj
- the object the serializeerrorMessage
- the message to show if serialization failspublic static Serializable deserialize(byte[] bytes) throws IOException, ClassNotFoundException
bytes
- the byte array to deserializeIOException
- if the deserialization failsClassNotFoundException
- if no class found to deserialize intopublic static Serializable deserialize(byte[] bytes, String errorMessage)
#deserialize(Object)
which throws a runtime exception with the given
message on failure.bytes
- the byte array the deserializeerrorMessage
- the message to show if deserialization failspublic static <S,T extends Serializable> Map<S,ArrayList<T>> makeValuesSerializable(Map<S,Collection<T>> map)
S
- the key type for the MapT
- the type of the values in the collections which are the values for the Mapmap
- a map to make serializablepublic static String parseBenchmarkResult(String result)
result
- the output of benchmarkCopyright © 2023. All Rights Reserved.