SerializersModuleCollector

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.

Not stable for inheritance

SerializersModuleCollector interface is not stable for inheritance in 3rd party libraries, as new methods might be added to this interface or contracts of the existing methods can be changed.

Inheritors

Functions

Link copied to clipboard
abstract fun <T : Any> contextual(kClass: KClass<T>, provider: (typeArgumentsSerializers: List<KSerializer<*>>) -> KSerializer<*>)

Accept a provider, associated with generic kClass for contextual serialization.

open fun <T : Any> contextual(kClass: KClass<T>, serializer: KSerializer<T>)

Accept a serializer, associated with kClass for contextual serialization.

Link copied to clipboard
abstract fun <Base : Any, Sub : Base> polymorphic(baseClass: KClass<Base>, actualClass: KClass<Sub>, actualSerializer: KSerializer<Sub>)

Accept a serializer, associated with actualClass for polymorphic serialization.

Link copied to clipboard
abstract fun <Base : Any> polymorphicDefaultDeserializer(baseClass: KClass<Base>, defaultDeserializerProvider: (className: String?) -> DeserializationStrategy<Base>?)

Accept a default deserializer provider, associated with the baseClass for polymorphic deserialization. defaultDeserializerProvider is invoked when no polymorphic serializers associated with the className in the scope of baseClass were found. className could be null for formats that support nullable class discriminators (currently only Json with useArrayPolymorphism set to false).

Link copied to clipboard
abstract fun <Base : Any> polymorphicDefaultSerializer(baseClass: KClass<Base>, defaultSerializerProvider: (value: Base) -> SerializationStrategy<Base>?)

Accept a default serializer provider, associated with the baseClass for polymorphic serialization. defaultSerializerProvider is invoked when no polymorphic serializers for value in the scope of baseClass were found.