Class CompactSerializationConfig
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.
- Since:
- 5.2
-
Constructor Summary
ConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionRegisters the class to be serialized with Compact serialization.addSerializer
(CompactSerializer<T> serializer) Registers the given Compact serializer.boolean
int
hashCode()
setClasses
(Class<?>... classes) Registers multiple classes to be serialized with Compact serialization.setSerializers
(CompactSerializer<?>... serializers) Registers the given Compact serializers.
-
Constructor Details
-
CompactSerializationConfig
public CompactSerializationConfig() -
CompactSerializationConfig
-
-
Method Details
-
addClass
Registers the class to be serialized with Compact serialization.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.
- Parameters:
clazz
- Class to be serialized with Compact serialization- Returns:
- configured
CompactSerializationConfig
for chaining
-
setClasses
Registers multiple classes to be serialized with Compact serialization.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.
- Parameters:
classes
- Classes to be serialized with Compact serialization- Returns:
- configured
CompactSerializationConfig
for chaining
-
addSerializer
Registers the given Compact 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.- Parameters:
serializer
- Serializer to be registered- Returns:
- configured
CompactSerializationConfig
for chaining
-
setSerializers
Registers the given Compact 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.
- Parameters:
serializers
- Serializers to be registered- Returns:
- configured
CompactSerializationConfig
for chaining
-
equals
-
hashCode
public int hashCode()
-