now Module is not serializable and instead of Serializer was created ModuleDeserializationStrategy

This commit is contained in:
InsanusMokrassar 2020-02-13 16:41:04 +06:00
parent cee263adb6
commit 2748c3f861
3 changed files with 6 additions and 10 deletions

View File

@ -3,7 +3,8 @@
## 0.1.2
* All reflection support methods are internal
* Added `lodModule` functions for more useful working with modules loading
* Added `loadModule` functions for more useful working with modules loading
* `Module` now is not serializable and can be created only via `loadModule` functions
## 0.1.1

View File

@ -4,4 +4,4 @@ import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.json.Json
@ImplicitReflectionSerializer
fun loadModule(json: String): Module = Json.nonstrict.parse(Module.serializer(), json)
fun loadModule(json: String): Module = Json.nonstrict.parse(ModuleDeserializerStrategy, json)

View File

@ -6,13 +6,10 @@ import kotlinx.serialization.internal.HashMapSerializer
import kotlinx.serialization.internal.StringSerializer
import kotlinx.serialization.json.*
@ImplicitReflectionSerializer
@Serializable(ModuleSerializer::class)
class Module(base: Map<String, @ContextualSerialization Any>) : Map<String, Any> by base
class Module internal constructor(base: Map<String, @ContextualSerialization Any>) : Map<String, Any> by base
@ImplicitReflectionSerializer
@Serializer(Module::class)
internal object ModuleSerializer : KSerializer<Module> {
internal object ModuleDeserializerStrategy : DeserializationStrategy<Module> {
private val internalSerializer = HashMapSerializer(StringSerializer, ContextSerializer(Any::class))
override val descriptor: SerialDescriptor
get() = internalSerializer.descriptor
@ -27,7 +24,5 @@ internal object ModuleSerializer : KSerializer<Module> {
return Module(map)
}
override fun serialize(encoder: Encoder, obj: Module) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun patch(decoder: Decoder, old: Module): Module = throw UpdateNotSupportedException("Module")
}