diff --git a/CHANGELOG.md b/CHANGELOG.md index f9b7aad..3ad891f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/commonMain/kotlin/com/insanusmokrassar/sdi/HelperTools.kt b/src/commonMain/kotlin/com/insanusmokrassar/sdi/HelperTools.kt index dc40876..f746b5c 100644 --- a/src/commonMain/kotlin/com/insanusmokrassar/sdi/HelperTools.kt +++ b/src/commonMain/kotlin/com/insanusmokrassar/sdi/HelperTools.kt @@ -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) diff --git a/src/commonMain/kotlin/com/insanusmokrassar/sdi/ModuleSerializer.kt b/src/commonMain/kotlin/com/insanusmokrassar/sdi/ModuleSerializer.kt index 267f021..5f3ad09 100644 --- a/src/commonMain/kotlin/com/insanusmokrassar/sdi/ModuleSerializer.kt +++ b/src/commonMain/kotlin/com/insanusmokrassar/sdi/ModuleSerializer.kt @@ -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) : Map by base +class Module internal constructor(base: Map) : Map by base @ImplicitReflectionSerializer -@Serializer(Module::class) -internal object ModuleSerializer : KSerializer { +internal object ModuleDeserializerStrategy : DeserializationStrategy { private val internalSerializer = HashMapSerializer(StringSerializer, ContextSerializer(Any::class)) override val descriptor: SerialDescriptor get() = internalSerializer.descriptor @@ -27,7 +24,5 @@ internal object ModuleSerializer : KSerializer { 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") }