From 5043eec7a2b86e068fa410b0cd257bb992b32b22 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 27 Jun 2022 23:35:10 +0600 Subject: [PATCH 1/6] start 0.11.7 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87362ac78ab..34ea789d010 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.11.7 + ## 0.11.6 * `FSM`: diff --git a/gradle.properties b/gradle.properties index 835cff3d3c3..d4794a30290 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.11.6 -android_code_version=130 +version=0.11.7 +android_code_version=131 From 7ac12455c820c35eb27e34026c08e90655cc757b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 28 Jun 2022 00:19:25 +0600 Subject: [PATCH 2/6] add ReadCRUDRepo mappers --- CHANGELOG.md | 4 ++ .../micro_utils/repos/mappers/CRUDMappers.kt | 42 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 34ea789d010..aa1755adb01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.11.7 +* `Repos`: + * `Common`: + * Add mappers for `ReadCRUDRepo` + ## 0.11.6 * `FSM`: diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt new file mode 100644 index 00000000000..0f9e45e58c0 --- /dev/null +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt @@ -0,0 +1,42 @@ +package dev.inmo.micro_utils.repos.mappers + +import dev.inmo.micro_utils.pagination.* +import dev.inmo.micro_utils.repos.* + +open class MapperReadCRUDRepo( + private val to: ReadCRUDRepo, + mapper: MapperRepo +) : ReadCRUDRepo, MapperRepo by mapper { + override suspend fun getByPagination( + pagination: Pagination + ): PaginationResult = to.getByPagination( + pagination + ).let { + it.changeResultsUnchecked( + it.results.map { it.toInnerValue() } + ) + } + + override suspend fun count(): Long = to.count() + + override suspend fun contains(id: FromId): Boolean = to.contains(id.toOutKey()) + + override suspend fun getById(id: FromId): FromRegistered? = to.getById( + id.toOutKey() + ) ?.toInnerValue() +} + +@Suppress("NOTHING_TO_INLINE") +inline fun ReadCRUDRepo.withMapper( + mapper: MapperRepo +): ReadCRUDRepo = MapperReadCRUDRepo(this, mapper) + +@Suppress("NOTHING_TO_INLINE") +inline fun ReadCRUDRepo.withMapper( + crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, +): ReadCRUDRepo = withMapper( + mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) +) From b40c09391789aa4cf745a3cf633df5fd42bc6596 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 28 Jun 2022 00:56:51 +0600 Subject: [PATCH 3/6] SimpleMapper, SimpleSuspendableMapper, mappers for CRUDRepo --- CHANGELOG.md | 4 +- .../dev/inmo/micro_utils/common/Mapper.kt | 53 +++++++++++ .../dev/inmo/micro_utils/repos/MapperRepo.kt | 13 +++ .../micro_utils/repos/mappers/CRUDMappers.kt | 89 +++++++++++++++++++ 4 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Mapper.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index aa1755adb01..5daa01e3045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,11 @@ ## 0.11.7 +* `Common`: + * New abstractions `SimpleMapper` and `SimpleSuspendableMapper` * `Repos`: * `Common`: - * Add mappers for `ReadCRUDRepo` + * Add mappers for `CRUDRepo` ## 0.11.6 diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Mapper.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Mapper.kt new file mode 100644 index 00000000000..5fcee5a2749 --- /dev/null +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Mapper.kt @@ -0,0 +1,53 @@ +package dev.inmo.micro_utils.common + +interface SimpleMapper { + fun t1(from: T2): T1 + fun t2(from: T1): T2 + + operator fun T2.invoke(): T1 = t1(this) + operator fun T1.invoke(): T2 = t2(this) + + fun T2.convert(): T1 = t1(this) + fun T1.convert(): T2 = t2(this) +} + +class SimpleMapperImpl( + private val t1: (T2) -> T1, + private val t2: (T1) -> T2, +) : SimpleMapper { + override fun t1(from: T2): T1 = t1.invoke(from) + + override fun t2(from: T1): T2 = t2.invoke(from) +} + +@Suppress("NOTHING_TO_INLINE") +inline fun simpleMapper( + noinline t1: (T2) -> T1, + noinline t2: (T1) -> T2, +) = SimpleMapperImpl(t1, t2) + +interface SimpleSuspendableMapper { + suspend fun t1(from: T2): T1 + suspend fun t2(from: T1): T2 + + suspend operator fun T2.invoke(): T1 = t1(this) + suspend operator fun T1.invoke(): T2 = t2(this) + + suspend fun T2.convert(): T1 = t1(this) + suspend fun T1.convert(): T2 = t2(this) +} + +class SimpleSuspendableMapperImpl( + private val t1: suspend (T2) -> T1, + private val t2: suspend (T1) -> T2, +) : SimpleSuspendableMapper { + override suspend fun t1(from: T2): T1 = t1.invoke(from) + + override suspend fun t2(from: T1): T2 = t2.invoke(from) +} + +@Suppress("NOTHING_TO_INLINE") +inline fun simpleSuspendableMapper( + noinline t1: suspend (T2) -> T1, + noinline t2: suspend (T1) -> T2, +) = SimpleSuspendableMapperImpl(t1, t2) diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt index 313c7970f60..cb207e0972a 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt @@ -1,7 +1,20 @@ package dev.inmo.micro_utils.repos +import dev.inmo.micro_utils.common.* + @Suppress("UNCHECKED_CAST") interface MapperRepo { + val keyMapper: SimpleSuspendableMapper + get() = simpleSuspendableMapper( + { it.toInnerKey() }, + { it.toOutKey() } + ) + val valueMapper: SimpleSuspendableMapper + get() = simpleSuspendableMapper( + { it.toInnerValue() }, + { it.toOutValue() } + ) + suspend fun FromKey.toOutKey() = this as ToKey suspend fun FromValue.toOutValue() = this as ToValue diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt index 0f9e45e58c0..82cb94d72b8 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt @@ -1,7 +1,11 @@ package dev.inmo.micro_utils.repos.mappers +import dev.inmo.micro_utils.common.SimpleSuspendableMapper +import dev.inmo.micro_utils.common.simpleSuspendableMapper import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.repos.* +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map open class MapperReadCRUDRepo( private val to: ReadCRUDRepo, @@ -40,3 +44,88 @@ inline fun ): ReadCRUDRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) + +open class MapperWriteCRUDRepo( + private val to: WriteCRUDRepo, + mapper: MapperRepo, + inputMapper: SimpleSuspendableMapper +) : WriteCRUDRepo, + MapperRepo by mapper, + SimpleSuspendableMapper by inputMapper { + override val newObjectsFlow: Flow = to.newObjectsFlow.map { it.toInnerValue() } + override val updatedObjectsFlow: Flow = to.updatedObjectsFlow.map { it.toInnerValue() } + override val deletedObjectsIdsFlow: Flow = to.deletedObjectsIdsFlow.map { it.toInnerKey() } + + override suspend fun deleteById(ids: List) = to.deleteById(ids.map { it.toOutKey() }) + + override suspend fun update( + values: List> + ): List = to.update( + values.map { + it.first.toOutKey() to it.second.convert() + } + ).map { it.toInnerValue() } + + override suspend fun update( + id: FromId, + value: FromInput + ): FromRegistered? = to.update(id.toOutKey(), value.convert()) ?.toInnerValue() + + override suspend fun create(values: List): List = to.create( + values.map { + it.convert() + } + ).map { + it.toInnerValue() + } + +} + +@Suppress("NOTHING_TO_INLINE") +inline fun WriteCRUDRepo.withMapper( + mapper: MapperRepo, + simpleSuspendableMapper: SimpleSuspendableMapper +): WriteCRUDRepo = MapperWriteCRUDRepo(this, mapper, simpleSuspendableMapper) + +@Suppress("NOTHING_TO_INLINE") +inline fun WriteCRUDRepo.withMapper( + crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + crossinline inputFromToTo: suspend FromInput.() -> ToInput = { this as ToInput }, + crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + crossinline inputToToFrom: suspend ToInput.() -> FromInput = { this as FromInput }, +): WriteCRUDRepo = withMapper( + mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom), + simpleSuspendableMapper({ inputToToFrom(it) }, { inputFromToTo(it) }) +) + +@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") +open class MapperCRUDRepo( + private val to: CRUDRepo, + private val mapper: MapperRepo, + private val inputMapper: SimpleSuspendableMapper +) : CRUDRepo, + MapperRepo by mapper, + ReadCRUDRepo by MapperReadCRUDRepo(to, mapper), + WriteCRUDRepo by MapperWriteCRUDRepo(to, mapper, inputMapper) + + +@Suppress("NOTHING_TO_INLINE") +inline fun CRUDRepo.withMapper( + mapper: MapperRepo, + simpleSuspendableMapper: SimpleSuspendableMapper +): CRUDRepo = MapperCRUDRepo(this, mapper, simpleSuspendableMapper) + +@Suppress("NOTHING_TO_INLINE") +inline fun CRUDRepo.withMapper( + crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + crossinline inputFromToTo: suspend FromInput.() -> ToInput = { this as ToInput }, + crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + crossinline inputToToFrom: suspend ToInput.() -> FromInput = { this as FromInput }, +): CRUDRepo = withMapper( + mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom), + simpleSuspendableMapper({ inputToToFrom(it) }, { inputFromToTo(it) }) +) From 12a7e3c4af840b5589dfb9ede86de229cc82f467 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 28 Jun 2022 01:06:46 +0600 Subject: [PATCH 4/6] fixes --- .../dev/inmo/micro_utils/common/Mapper.kt | 40 +++++++++---------- .../micro_utils/repos/mappers/CRUDMappers.kt | 9 ++--- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Mapper.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Mapper.kt index 5fcee5a2749..3494ebfff1b 100644 --- a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Mapper.kt +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/Mapper.kt @@ -1,23 +1,24 @@ package dev.inmo.micro_utils.common +import kotlin.jvm.JvmName + interface SimpleMapper { - fun t1(from: T2): T1 - fun t2(from: T1): T2 - - operator fun T2.invoke(): T1 = t1(this) - operator fun T1.invoke(): T2 = t2(this) - - fun T2.convert(): T1 = t1(this) - fun T1.convert(): T2 = t2(this) + fun convertToT1(from: T2): T1 + fun convertToT2(from: T1): T2 } +@JvmName("convertFromT2") +fun SimpleMapper.convert(from: T2) = convertToT1(from) +@JvmName("convertFromT1") +fun SimpleMapper.convert(from: T1) = convertToT2(from) + class SimpleMapperImpl( private val t1: (T2) -> T1, private val t2: (T1) -> T2, ) : SimpleMapper { - override fun t1(from: T2): T1 = t1.invoke(from) + override fun convertToT1(from: T2): T1 = t1.invoke(from) - override fun t2(from: T1): T2 = t2.invoke(from) + override fun convertToT2(from: T1): T2 = t2.invoke(from) } @Suppress("NOTHING_TO_INLINE") @@ -27,23 +28,22 @@ inline fun simpleMapper( ) = SimpleMapperImpl(t1, t2) interface SimpleSuspendableMapper { - suspend fun t1(from: T2): T1 - suspend fun t2(from: T1): T2 - - suspend operator fun T2.invoke(): T1 = t1(this) - suspend operator fun T1.invoke(): T2 = t2(this) - - suspend fun T2.convert(): T1 = t1(this) - suspend fun T1.convert(): T2 = t2(this) + suspend fun convertToT1(from: T2): T1 + suspend fun convertToT2(from: T1): T2 } +@JvmName("convertFromT2") +suspend fun SimpleSuspendableMapper.convert(from: T2) = convertToT1(from) +@JvmName("convertFromT1") +suspend fun SimpleSuspendableMapper.convert(from: T1) = convertToT2(from) + class SimpleSuspendableMapperImpl( private val t1: suspend (T2) -> T1, private val t2: suspend (T1) -> T2, ) : SimpleSuspendableMapper { - override suspend fun t1(from: T2): T1 = t1.invoke(from) + override suspend fun convertToT1(from: T2): T1 = t1.invoke(from) - override suspend fun t2(from: T1): T2 = t2.invoke(from) + override suspend fun convertToT2(from: T1): T2 = t2.invoke(from) } @Suppress("NOTHING_TO_INLINE") diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt index 82cb94d72b8..40543da0eba 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt @@ -1,7 +1,6 @@ package dev.inmo.micro_utils.repos.mappers -import dev.inmo.micro_utils.common.SimpleSuspendableMapper -import dev.inmo.micro_utils.common.simpleSuspendableMapper +import dev.inmo.micro_utils.common.* import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.repos.* import kotlinx.coroutines.flow.Flow @@ -62,18 +61,18 @@ open class MapperWriteCRUDRepo> ): List = to.update( values.map { - it.first.toOutKey() to it.second.convert() + it.first.toOutKey() to convert(it.second) } ).map { it.toInnerValue() } override suspend fun update( id: FromId, value: FromInput - ): FromRegistered? = to.update(id.toOutKey(), value.convert()) ?.toInnerValue() + ): FromRegistered? = to.update(id.toOutKey(), convert(value)) ?.toInnerValue() override suspend fun create(values: List): List = to.create( values.map { - it.convert() + convert(it) } ).map { it.toInnerValue() From 9132e216c969312b14c75fa17853587aff1579e5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 28 Jun 2022 01:43:57 +0600 Subject: [PATCH 5/6] add several extensions for MapperRepo --- .../dev/inmo/micro_utils/repos/MapperRepo.kt | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt index cb207e0972a..3fdf345e073 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapperRepo.kt @@ -20,16 +20,32 @@ interface MapperRepo { suspend fun ToKey.toInnerKey() = this as FromKey suspend fun ToValue.toInnerValue() = this as FromValue + + companion object } -inline fun mapper( - crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, - crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, - crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, - crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, -) = object : MapperRepo { +class SimpleMapperRepo( + private val keyFromToTo: suspend FromKey.() -> ToKey, + private val valueFromToTo: suspend FromValue.() -> ToValue, + private val keyToToFrom: suspend ToKey.() -> FromKey, + private val valueToToFrom: suspend ToValue.() -> FromValue +) : MapperRepo { override suspend fun FromKey.toOutKey(): ToKey = keyFromToTo() override suspend fun FromValue.toOutValue(): ToValue = valueFromToTo() override suspend fun ToKey.toInnerKey(): FromKey = keyToToFrom() override suspend fun ToValue.toInnerValue(): FromValue = valueToToFrom() } + +operator fun MapperRepo.Companion.invoke( + keyFromToTo: suspend FromKey.() -> ToKey, + valueFromToTo: suspend FromValue.() -> ToValue, + keyToToFrom: suspend ToKey.() -> FromKey, + valueToToFrom: suspend ToValue.() -> FromValue +) = SimpleMapperRepo(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) + +inline fun mapper( + noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, +) = MapperRepo(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) From abbea906f172205b137fdd53be4db0453965875e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 28 Jun 2022 01:46:24 +0600 Subject: [PATCH 6/6] fixes --- .../micro_utils/repos/mappers/CRUDMappers.kt | 32 +++++++++---------- .../repos/mappers/KeyValueMappers.kt | 24 +++++++------- .../repos/mappers/OneToManyKeyValueMappers.kt | 24 +++++++------- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt index 40543da0eba..97894431d7b 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/CRUDMappers.kt @@ -36,10 +36,10 @@ inline fun ReadCRUDRepo.wit @Suppress("NOTHING_TO_INLINE") inline fun ReadCRUDRepo.withMapper( - crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, - crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, - crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, - crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, ): ReadCRUDRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) @@ -88,12 +88,12 @@ inline fun WriteCRUDRep @Suppress("NOTHING_TO_INLINE") inline fun WriteCRUDRepo.withMapper( - crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, - crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, - crossinline inputFromToTo: suspend FromInput.() -> ToInput = { this as ToInput }, - crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, - crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, - crossinline inputToToFrom: suspend ToInput.() -> FromInput = { this as FromInput }, + noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + noinline inputFromToTo: suspend FromInput.() -> ToInput = { this as ToInput }, + noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + noinline inputToToFrom: suspend ToInput.() -> FromInput = { this as FromInput }, ): WriteCRUDRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom), simpleSuspendableMapper({ inputToToFrom(it) }, { inputFromToTo(it) }) @@ -118,12 +118,12 @@ inline fun CRUDRepo CRUDRepo.withMapper( - crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, - crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, - crossinline inputFromToTo: suspend FromInput.() -> ToInput = { this as ToInput }, - crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, - crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, - crossinline inputToToFrom: suspend ToInput.() -> FromInput = { this as FromInput }, + noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + noinline inputFromToTo: suspend FromInput.() -> ToInput = { this as ToInput }, + noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + noinline inputToToFrom: suspend ToInput.() -> FromInput = { this as FromInput }, ): CRUDRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom), simpleSuspendableMapper({ inputToToFrom(it) }, { inputFromToTo(it) }) diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/KeyValueMappers.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/KeyValueMappers.kt index 23955920fe8..4df2b614f6e 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/KeyValueMappers.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/KeyValueMappers.kt @@ -77,10 +77,10 @@ inline fun ReadKeyValueRepo @Suppress("NOTHING_TO_INLINE") inline fun ReadKeyValueRepo.withMapper( - crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, - crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, - crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, - crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, ): ReadKeyValueRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) @@ -122,10 +122,10 @@ inline fun WriteKeyValueRepo WriteKeyValueRepo.withMapper( - crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, - crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, - crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, - crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, ): WriteKeyValueRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) @@ -148,10 +148,10 @@ inline fun KeyValueRepo.wit @Suppress("NOTHING_TO_INLINE") inline fun KeyValueRepo.withMapper( - crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, - crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, - crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, - crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, ): KeyValueRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt index 5e5d5b44d5f..f74b81d9149 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/mappers/OneToManyKeyValueMappers.kt @@ -75,10 +75,10 @@ inline fun ReadKeyValuesRepo ReadKeyValuesRepo.withMapper( - crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, - crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, - crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, - crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, ): ReadKeyValuesRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) @@ -128,10 +128,10 @@ inline fun WriteKeyValuesRepo WriteKeyValuesRepo.withMapper( - crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, - crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, - crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, - crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, ): WriteKeyValuesRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) ) @@ -154,10 +154,10 @@ inline fun KeyValuesRepo.wi @Suppress("NOTHING_TO_INLINE") inline fun KeyValuesRepo.withMapper( - crossinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, - crossinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, - crossinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, - crossinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, + noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, + noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, + noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, + noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, ): KeyValuesRepo = withMapper( mapper(keyFromToTo, valueFromToTo, keyToToFrom, valueToToFrom) )