mirror of
https://github.com/InsanusMokrassar/SDI.git
synced 2024-06-01 23:45:12 +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
|
* 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
|
* 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
|
## 0.2.0
|
||||||
|
|
||||||
* `Kotlin`: `1.3.61` -> `1.3.70`
|
* `Kotlin`: `1.3.61` -> `1.3.70`
|
||||||
|
|
|
@ -17,7 +17,7 @@ plugins {
|
||||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
project.version = "0.3.0"
|
project.version = "0.3.1"
|
||||||
project.group = "com.insanusmokrassar"
|
project.group = "com.insanusmokrassar"
|
||||||
|
|
||||||
apply from: "publish.gradle"
|
apply from: "publish.gradle"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin_version=1.3.71
|
kotlin_version=1.3.72
|
||||||
kotlin_serialisation_runtime_version=0.20.0
|
kotlin_serialisation_runtime_version=0.20.0
|
||||||
|
|
||||||
gradle_bintray_plugin_version=1.8.4
|
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