Type Handling
The serializer uses EclipseStore’s type handling system. This includes automatic registration of new types during serialization and legacy type mapping when deserializing data written by a previous version of your classes.
Type Registration
Types can be registered explicitly using the SerializerFoundation:
final SerializerFoundation<?> foundation = SerializerFoundation.New()
.registerEntityTypes(Customer.class, Order.class, Product.class);
When a type is encountered during serialization that has not been registered, the serializer registers it automatically. However, explicitly registering types is recommended because:
-
It ensures consistent type IDs across serializer instances
-
It avoids issues when deserializing with a different instance
-
It provides a clear documentation of which types are involved in serialization
TypeDictionary
The serializer internally generates a dictionary that describes all serialized types. This dictionary maps type IDs to their structure (field names and types) and can be exported and imported to exchange type information between different serializer instances.
Exporting the Type Dictionary
The current type information can be obtained as a String using the serializer’s exportTypeDictionary() method:
final String typeDictionaryString = serializer.exportTypeDictionary();
The exported string contains a human-readable representation of all registered types and their structures. This can be stored to a file or transferred to another system.
Importing the Type Dictionary
To import an initial type dictionary, supply it as a String to the SerializerFoundation before creating the serializer instance:
New(String typeDictionaryString) method:final SerializerFoundation<?> foundation = SerializerFoundation.New(typeDictionaryString);
setInitialTypeDictionary(String typeDictionaryString) method:final SerializerFoundation<?> foundation = SerializerFoundation.New();
foundation.setInitialTypeDictionary(typeDictionaryString);
Type Evolution
When a class changes between serialization and deserialization (fields added, removed, renamed, or retyped), the serializer’s legacy type mapping system handles the conversion automatically in many cases.
For more details, see Legacy Type Mapping.