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).
CharSequence
s, including String
s (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 void writeSerializable(Bytes bytes, Object object, Class expectedClass) throws IOException
ObjectSerializer
writeSerializable
in interface ObjectSerializer
bytes
- to write toobject
- object to writeexpectedClass
- which will be provided on read, can be nullIOException
public <T> T readSerializable(@NotNull Bytes bytes, Class<T> expectedClass, T object) throws IOException, ClassNotFoundException
ObjectSerializer
readSerializable
in interface ObjectSerializer
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 createdpublic static ObjectSerializer create()
public static ObjectSerializer create(BytesMarshallerFactory bytesMarshallerFactory, ObjectSerializer instance)
Copyright © 2019. All rights reserved.