public class BytesMarshallableSerializer extends Object implements ObjectSerializer
BytesMarshallable objects, compact String encoding and support of pluggable custom
serializers for arbitrary classes.
BytesMarshallableSerializer could benefit if objects (either top-level serialized or
nested fields) implement BytesMarshallable interface the same way as built-in
serialization benefit if objects implement Externalizable (of cause, BytesMarshallableSerializer supports Externalizable too).
CharSequences, including Strings (either top-level serialized or nested
fields) are serialized in UTF-8 encoding.
Custom per-class serializers are held by BytesMarshallerFactory, which could be
passed via constructor or static factory create() method.
| Modifier | Constructor and Description |
|---|---|
protected |
BytesMarshallableSerializer(BytesMarshallerFactory bytesMarshallerFactory,
ObjectSerializer objectSerializer) |
| Modifier and Type | Method and Description |
|---|---|
static ObjectSerializer |
create() |
static ObjectSerializer |
create(BytesMarshallerFactory bytesMarshallerFactory,
ObjectSerializer instance) |
<T> T |
readSerializable(Bytes bytes,
Class<T> expectedClass,
T object)
Read an object
|
void |
writeSerializable(Bytes bytes,
Object object,
Class expectedClass)
write an object
|
protected BytesMarshallableSerializer(BytesMarshallerFactory bytesMarshallerFactory, ObjectSerializer objectSerializer)
public static ObjectSerializer create()
public static ObjectSerializer create(BytesMarshallerFactory bytesMarshallerFactory, ObjectSerializer instance)
public void writeSerializable(Bytes bytes, Object object, Class expectedClass) throws IOException
ObjectSerializerwriteSerializable in interface ObjectSerializerbytes - to write toobject - object to writeexpectedClass - which will be provided on read, can be nullIOExceptionpublic <T> T readSerializable(@NotNull Bytes bytes, Class<T> expectedClass, T object) throws IOException, ClassNotFoundException
ObjectSerializerreadSerializable in interface ObjectSerializerbytes - 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.