Relaxed type restriction on MetaConverter

This commit is contained in:
Alexander Nozik 2021-06-23 08:20:22 +03:00
parent 9d3c7149b7
commit 474597777c
3 changed files with 5 additions and 4 deletions

View File

@ -8,6 +8,7 @@
- **API breaking** Descriptor no has a member property `defaultValue` instead of `defaultItem()` extension. It caches default value state on the first call. It is done because computing default on each call is too expensive.
- Kotlin 1.5.10
- Build tools 0.10.0
- Relaxed type restriction on `MetaConverter`. Now nullables are available.
### Deprecated

View File

@ -4,7 +4,7 @@ plugins {
allprojects {
group = "space.kscience"
version = "0.4.3"
version = "0.4.4-dev-1"
}
subprojects {

View File

@ -6,7 +6,7 @@ import space.kscience.dataforge.values.*
/**
* A converter of generic object to and from [TypedMetaItem]
*/
public interface MetaConverter<T : Any> {
public interface MetaConverter<T> {
public fun itemToObject(item: MetaItem): T
public fun objectToMetaItem(obj: T): MetaItem
@ -120,5 +120,5 @@ public interface MetaConverter<T : Any> {
public fun <T : Any> MetaConverter<T>.nullableItemToObject(item: MetaItem?): T? = item?.let { itemToObject(it) }
public fun <T : Any> MetaConverter<T>.nullableObjectToMetaItem(obj: T?): MetaItem? = obj?.let { objectToMetaItem(it) }
public fun <T : Any> MetaConverter<T>.metaToObject(meta: Meta): T = itemToObject(MetaItemNode(meta))
public fun <T : Any> MetaConverter<T>.valueToObject(value: Value): T = itemToObject(MetaItemValue(value))
public fun <T> MetaConverter<T>.metaToObject(meta: Meta): T = itemToObject(MetaItemNode(meta))
public fun <T> MetaConverter<T>.valueToObject(value: Value): T = itemToObject(MetaItemValue(value))