mirror of
https://github.com/InsanusMokrassar/SDI.git
synced 2024-11-27 04:28:53 +00:00
Merge branch '0.3.1' of InsanusMokrassar/SDI into master
This commit is contained in:
commit
1fc3dba66a
@ -9,6 +9,11 @@
|
||||
* Now it will correctly resolve objects which was not previously registered
|
||||
* By default, for modules loading will be used context from `Json`, passed as receiver
|
||||
|
||||
### 0.3.1
|
||||
|
||||
* `Kotlin`: `1.3.71` -> `1.3.72`
|
||||
* Add `SerializersModuleBuilder#optionalContextual` for more comfortable usage of `contextual`
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* `Kotlin`: `1.3.61` -> `1.3.70`
|
||||
|
@ -17,7 +17,7 @@ plugins {
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||
}
|
||||
|
||||
project.version = "0.3.0"
|
||||
project.version = "0.3.1"
|
||||
project.group = "com.insanusmokrassar"
|
||||
|
||||
apply from: "publish.gradle"
|
||||
|
@ -1,5 +1,5 @@
|
||||
kotlin.code.style=official
|
||||
kotlin_version=1.3.71
|
||||
kotlin_version=1.3.72
|
||||
kotlin_serialisation_runtime_version=0.20.0
|
||||
|
||||
gradle_bintray_plugin_version=1.8.4
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.insanusmokrassar.sdi.utils
|
||||
|
||||
import kotlinx.serialization.InternalSerializationApi
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.modules.*
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@InternalSerializationApi
|
||||
fun <T : Any> SerializersModuleBuilder.optionalContextual(
|
||||
kClass: KClass<T>, kSerializer: KSerializer<T>
|
||||
) = try {
|
||||
contextual(kClass, kSerializer)
|
||||
true
|
||||
} catch (e: SerializerAlreadyRegisteredException) {
|
||||
false
|
||||
}
|
||||
|
||||
@InternalSerializationApi
|
||||
inline fun <reified T : Any> SerializersModuleBuilder.optionalContextual(
|
||||
kSerializer: KSerializer<T>
|
||||
) = optionalContextual(T::class, kSerializer)
|
Loading…
Reference in New Issue
Block a user