Package-level declarations
Classes that provides runtime mechanisms for resolving serializers, typically used during polymorphic serialization.
Types
A builder which registers all its content for polymorphic serialization in the scope of the base class. If baseSerializer is present, registers it as a serializer for baseClass (which will be used if base class is serializable). Subclasses and its serializers can be added with subclass builder function.
SerializersModule is a collection of serializers used by ContextualSerializer and PolymorphicSerializer to override or provide serializers at the runtime, whereas at the compile-time they provided by the serialization plugin. It can be considered as a map where serializers can be found using their statically known KClasses.
A builder class for SerializersModule DSL. To create an instance of builder, use SerializersModule factory function.
SerializersModuleCollector can introspect and accumulate content of any SerializersModule via SerializersModule.dumpTo, using a visitor-like pattern: contextual and polymorphic functions are invoked for each registered serializer.
Functions
Adds serializer associated with given type T for contextual serialization. Throws SerializationException if a module already has serializer associated with the given type. To overwrite an already registered serializer, SerializersModule.overwriteWith can be used.
A SerializersModule which is empty and returns null
from each method.
Returns a combination of two serial modules
Returns a combination of two serial modules
Creates a builder to register subclasses of a given baseClass for polymorphic serialization. If baseSerializer is not null, registers it as a serializer for baseClass, which is useful if the base class is serializable itself. To register subclasses, PolymorphicModuleBuilder.subclass builder function can be used.
A builder function for creating a SerializersModule. Serializers can be added via SerializersModuleBuilder.contextual or SerializersModuleBuilder.polymorphic. Since SerializersModuleBuilder also implements SerialModuleCollector, it is possible to copy whole another module to this builder with SerializersModule.dumpTo
Returns a SerializersModule which has one class with one serializer for ContextualSerializer.
Registers a serializer for class T in the resulting module under the base class.
Registers a subclass in the resulting module under the base class.