ModuleSerializer now can be instantiated automatically

This commit is contained in:
InsanusMokrassar 2021-02-22 18:42:08 +06:00
parent c8cae5c941
commit dbd9c1b484
2 changed files with 11 additions and 2 deletions

View File

@ -3,6 +3,8 @@
## 0.4.1 ## 0.4.1
* `Serialization`: `1.1.0-RC` -> `1.1.0` * `Serialization`: `1.1.0-RC` -> `1.1.0`
* `ModuleSerializer` now can be instantiated automatically
## 0.4.0 ## 0.4.0

View File

@ -94,9 +94,16 @@ internal data class SerializationContext(
@Serializer(Module::class) @Serializer(Module::class)
class ModuleSerializer( class ModuleSerializer(
private val moduleBuilder: (SerializersModuleBuilder.() -> Unit)? = null, private val additionalClassesToInclude: Iterable<KClass<*>>,
private vararg val additionalClassesToInclude: KClass<*> private val moduleBuilder: (SerializersModuleBuilder.() -> Unit)? = null
) : KSerializer<Module> { ) : KSerializer<Module> {
constructor() : this(emptyList()) // to be able to create default instance
constructor(
moduleBuilder: (SerializersModuleBuilder.() -> Unit)? = null,
vararg additionalClassesToInclude: KClass<*>,
) : this(additionalClassesToInclude.toList(), moduleBuilder)
private val jsonObjectSerializer = JsonObject.serializer() private val jsonObjectSerializer = JsonObject.serializer()
override val descriptor: SerialDescriptor = jsonObjectSerializer.descriptor override val descriptor: SerialDescriptor = jsonObjectSerializer.descriptor