public interface ObjectSerializer extends Serializable
ObjectSerializer abstracts
Java serialization re-implementations and extensions. Bytes is used as core IO interface
instead of InputStream + OutputStream pair, which Java built-in serialization
use. However, note that Bytes could always be converted to these old interfaces by
BytesCommon.inputStream() and BytesCommon.outputStream(), if needed.
The default fallback implementation is Java built-in serialization itself:
JDKObjectSerializer.
Another provided implementation is BytesMarshallableSerializer, which basically
extends built-in serialization with some improvements. For example, it could benefit if objects
implement BytesMarshallable interface the same way as built-in serialization benefit
if objects implement Externalizable. See BytesMarshallableSerializer docs for
more information.
This interface is supposed to be implemented to plug such third-party serialization re-implementations, as Kryo, fast-serialization, etc.
| Modifier and Type | Method and Description |
|---|---|
<T> T |
readSerializable(Bytes bytes,
Class<T> expectedClass,
T object)
Read an object
|
void |
writeSerializable(Bytes bytes,
Object object,
Class expectedClass)
write an object
|
void writeSerializable(@NotNull Bytes bytes, Object object, Class expectedClass) throws IOException
bytes - to write toobject - object to writeexpectedClass - which will be provided on read, can be nullIOException<T> T readSerializable(@NotNull Bytes bytes, Class<T> expectedClass, T object) throws IOException, ClassNotFoundException
bytes - to readexpectedClass - proved when writing, can be nullobject - to populate, can be nullIOException - if it not possible to serialize the objectClassNotFoundException - if the expectedClass can not be createdCopyright © 2019. All rights reserved.