SerializersModule
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.
To enable runtime serializers resolution, one of the special annotations must be used on target types (Polymorphic or Contextual), and a serial module with serializers should be used during construction of SerialFormat.
Serializers module can be built with SerializersModule {}
builder function. Empty module can be obtained with EmptySerializersModule()
factory function.
See also
Functions
Copies contents of this module to the given collector.
Returns a contextual serializer associated with a given kClass. If given class has generic parameters and module has provider for kClass, typeArgumentsSerializers are used to create serializer. This method is used in context-sensitive operations on a property marked with Contextual by a ContextualSerializer.
Looks up a descriptor of serializer registered for contextual serialization in this, using SerialDescriptor.capturedKClass as a key.
Returns a polymorphic serializer registered for a class of the given value in the scope of baseClass.
Returns a polymorphic deserializer registered for a serializedClassName in the scope of baseClass or default value constructed from serializedClassName if a default serializer provider was registered.
Retrieves a collection of descriptors which serializers are registered for polymorphic serialization in this with base class equal to descriptor's SerialDescriptor.capturedKClass. This method does not retrieve serializers registered with PolymorphicModuleBuilder.defaultDeserializer or PolymorphicModuleBuilder.defaultSerializer.
Returns a combination of two serial modules
Returns a combination of two serial modules
Retrieves default serializer for the given type T and, if T is not serializable, fallbacks to contextual lookup.
Retrieves default serializer for the given type and, if type is not serializable, fallbacks to contextual lookup. type argument is usually obtained with typeOf method.
Retrieves serializer for the given kClass and, if kClass is not serializable, fallbacks to contextual lookup. This method uses platform-specific reflection available.
Retrieves a serializer for the given type using reflective construction and contextual lookup as a fallback for non-serializable types.
Retrieves default serializer for the given type and, if type is not serializable, fallbacks to contextual lookup. type argument is usually obtained with typeOf method.
Retrieves a serializer for the given type using reflective construction and contextual lookup as a fallback for non-serializable types.