public class CompactSerializationConfig extends Object
Once enabled the classes which does not match to any other serialization methods will be serialized in the new format automatically via help of reflection without needing any other configuration. For this case, the class should not implement `Serializable`, `Externalizable`, `Portable`, `IdentifiedDataSerializable`, `DataSerializable` or the class should not be registered as a custom serializer.
For automatic serialization with reflection, only types in
CompactWriter
/CompactReader
interface and char
,
Character
, enum
, and their arrays are supported as fields.
For any other field type, the reflective serializer will work recursively and
try to de/serialize those as nested Compact objects.
To explicitly configure a class to be serialized with Compact format following methods can be used.
addSerializer(CompactSerializer)
setSerializers(CompactSerializer[])
addClass(Class)
setClasses(Class[])
On the first two methods listed above, reflection is not utilized. Instead, the given serializer is used to serialize/deserialize users objects.
Constructor and Description |
---|
CompactSerializationConfig() |
CompactSerializationConfig(CompactSerializationConfig config) |
Modifier and Type | Method and Description |
---|---|
<T> CompactSerializationConfig |
addClass(Class<T> clazz)
Registers the class to be serialized with Compact serialization.
|
<T> CompactSerializationConfig |
addSerializer(CompactSerializer<T> serializer)
Registers the given Compact serializer.
|
boolean |
equals(Object o) |
int |
hashCode() |
CompactSerializationConfig |
setClasses(Class<?>... classes)
Registers multiple classes to be serialized with Compact serialization.
|
CompactSerializationConfig |
setSerializers(CompactSerializer<?>... serializers)
Registers the given Compact serializers.
|
public CompactSerializationConfig()
public CompactSerializationConfig(CompactSerializationConfig config)
public <T> CompactSerializationConfig addClass(@Nonnull Class<T> clazz)
For the given class, Compact serialization will be used instead of Portable, Identified, Java Serializable, or GlobalSerializer.
Type name is determined automatically from the class, which is its fully qualified class name.
Field types are determined automatically from the class with reflection.
clazz
- Class to be serialized with Compact serializationCompactSerializationConfig
for chainingpublic CompactSerializationConfig setClasses(@Nonnull Class<?>... classes)
For the given classes, Compact serialization will be used instead of Portable, Identified, Java Serializable, or GlobalSerializer.
Type names are determined automatically from the classes, which are their fully qualified class names.
Field types are determined automatically from the classes with reflection.
This method will clear previous class registrations.
classes
- Classes to be serialized with Compact serializationCompactSerializationConfig
for chainingpublic <T> CompactSerializationConfig addSerializer(@Nonnull CompactSerializer<T> serializer)
For the class returned by the serializer's
CompactSerializer.getCompactClass()
method, Compact serialization
will be used instead of Portable, Identified, Java Serializable, or
GlobalSerializer.
Type name will be read from the serializer's
CompactSerializer.getTypeName()
method.
serializer
- Serializer to be registeredCompactSerializationConfig
for chainingpublic CompactSerializationConfig setSerializers(@Nonnull CompactSerializer<?>... serializers)
For the classes returned by the serializers'
CompactSerializer.getCompactClass()
method, Compact serialization
will be used instead of Portable, Identified, Java Serializable, or
GlobalSerializer.
Type names will be read from the serializers'
CompactSerializer.getTypeName()
method.
This method will clear previous serializer registrations.
serializers
- Serializers to be registeredCompactSerializationConfig
for chainingCopyright © 2024 Hazelcast, Inc.. All rights reserved.