@Beta 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.
Automatic serialization via reflection can de/serialize classes having an accessible empty constructor only.
Only types in CompactWriter
/CompactReader
interface are supported as fields.
For any other class as the field type, it will work recursively and try to de/serialize a sub-class.
Thus, if any sub-fields does not have an accessible empty constructor, deserialization fails with
HazelcastSerializationException.
To explicitly configure a class to be serialized via Compact format following methods can be used.
register(Class)
register(Class, String, CompactSerializer)
}
On the last two methods listed above reflection is not utilized instead given serializer is used to serialize/deserialize users objects.
Constructor and Description |
---|
CompactSerializationConfig() |
CompactSerializationConfig(CompactSerializationConfig compactSerializationConfig) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
Map<String,com.hazelcast.internal.util.TriTuple<Class,String,CompactSerializer>> |
getRegistries() |
int |
hashCode() |
boolean |
isEnabled()
This method will only be available during @Beta.
|
<T> CompactSerializationConfig |
register(Class<T> clazz)
Registers the class to be serialized via compact serializer.
|
<T> CompactSerializationConfig |
register(Class<T> clazz,
String typeName,
CompactSerializer<T> explicitSerializer)
Registers the class to be serialized via compact serializer.
|
CompactSerializationConfig |
setEnabled(boolean enabled)
Enables the Compact Format.
|
public CompactSerializationConfig()
public CompactSerializationConfig(CompactSerializationConfig compactSerializationConfig)
public <T> CompactSerializationConfig register(@Nonnull Class<T> clazz)
Overrides 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 via reflection.
clazz
- Class to be serialized via compact serializerCompactSerializationConfig
for chainingpublic <T> CompactSerializationConfig register(@Nonnull Class<T> clazz, @Nonnull String typeName, @Nonnull CompactSerializer<T> explicitSerializer)
Overrides Portable, Identified, Java Serializable, or GlobalSerializer.
clazz
- Class to be serialized via compact serializertypeName
- Type name of the classexplicitSerializer
- Serializer to be used for the given classCompactSerializationConfig
for chaining@Nonnull public Map<String,com.hazelcast.internal.util.TriTuple<Class,String,CompactSerializer>> getRegistries()
public boolean isEnabled()
public CompactSerializationConfig setEnabled(boolean enabled)
The final version will not be backward compatible with the Beta. Do not use BETA version in production
enabled
- Enables the Compact Format when set to trueCompactSerializationConfig
for chainingCopyright © 2022 Hazelcast, Inc.. All rights reserved.