@@ -34,18 +34,19 @@ public class PolymorphicModuleBuilder<in Base : Any> @PublishedApi internal cons
34
34
* Adds a default serializers provider associated with the given [baseClass] to the resulting module.
35
35
* [defaultDeserializerProvider] is invoked when no polymorphic serializers associated with the `className`
36
36
* were found. `className` could be `null` for formats that support nullable class discriminators
37
- * (currently only [Json] with [useArrayPolymorphism][JsonBuilder.useArrayPolymorphism] set to `false`)
37
+ * (currently only `Json` with `JsonBuilder.useArrayPolymorphism` set to `false`)
38
+ *
39
+ * Default deserializers provider affects only deserialization process. To affect serialization process, use
40
+ * [SerializersModuleBuilder.polymorphicDefaultSerializer].
38
41
*
39
42
* [defaultDeserializerProvider] can be stateful and lookup a serializer for the missing type dynamically.
40
43
*
41
44
* Typically, if the class is not registered in advance, it is not possible to know the structure of the unknown
42
45
* type and have a precise serializer, so the default serializer has limited capabilities.
43
- * To have a structural access to the unknown data, it is recommended to use [JsonTransformingSerializer]
44
- * or [JsonContentPolymorphicSerializer] classes.
46
+ * If you're using `Json` format, you can get a structural access to the unknown data using `JsonContentPolymorphicSerializer`.
45
47
*
46
- * Default deserializers provider affects only deserialization process.
48
+ * @see SerializersModuleBuilder.polymorphicDefaultSerializer
47
49
*/
48
- @ExperimentalSerializationApi
49
50
public fun defaultDeserializer (defaultDeserializerProvider : (className: String? ) -> DeserializationStrategy <Base >? ) {
50
51
require(this .defaultDeserializerProvider == null ) {
51
52
" Default deserializer provider is already registered for class $baseClass : ${this .defaultDeserializerProvider} "
@@ -55,26 +56,27 @@ public class PolymorphicModuleBuilder<in Base : Any> @PublishedApi internal cons
55
56
56
57
/* *
57
58
* Adds a default deserializers provider associated with the given [baseClass] to the resulting module.
59
+ * This function affect only deserialization process. To avoid confusion, it was deprecated and replaced with [defaultDeserializer].
60
+ * To affect serialization process, use [SerializersModuleBuilder.polymorphicDefaultSerializer].
61
+ *
58
62
* [defaultSerializerProvider] is invoked when no polymorphic serializers associated with the `className`
59
63
* were found. `className` could be `null` for formats that support nullable class discriminators
60
- * (currently only [ Json] with [useArrayPolymorphism][ JsonBuilder.useArrayPolymorphism] set to `false`)
64
+ * (currently only ` Json` with ` JsonBuilder.useArrayPolymorphism` set to `false`)
61
65
*
62
66
* [defaultSerializerProvider] can be stateful and lookup a serializer for the missing type dynamically.
63
67
*
64
- * [defaultSerializerProvider] is named as such for backwards compatibility reasons; it provides deserializers.
65
- *
66
68
* Typically, if the class is not registered in advance, it is not possible to know the structure of the unknown
67
69
* type and have a precise serializer, so the default serializer has limited capabilities.
68
- * To have a structural access to the unknown data, it is recommended to use [JsonTransformingSerializer]
69
- * or [JsonContentPolymorphicSerializer] classes.
70
- *
71
- * Default deserializers provider affects only deserialization process. To affect serialization process, use
72
- * [SerializersModuleBuilder.polymorphicDefaultSerializer].
70
+ * If you're using `Json` format, you can get a structural access to the unknown data using `JsonContentPolymorphicSerializer`.
73
71
*
74
72
* @see defaultDeserializer
73
+ * @see SerializersModuleBuilder.polymorphicDefaultSerializer
75
74
*/
76
- @OptIn(ExperimentalSerializationApi ::class )
77
- // TODO: deprecate in 1.4
75
+ @Deprecated(
76
+ " Deprecated in favor of function with more precise name: defaultDeserializer" ,
77
+ ReplaceWith (" defaultDeserializer(defaultSerializerProvider)" ),
78
+ DeprecationLevel .WARNING // Since 1.5.0. Raise to ERROR in 1.6.0, hide in 1.7.0
79
+ )
78
80
public fun default (defaultSerializerProvider : (className: String? ) -> DeserializationStrategy <Base >? ) {
79
81
defaultDeserializer(defaultSerializerProvider)
80
82
}
0 commit comments