From f74167cc6575e57d6c42516589ce3d3026769e8f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 11 Nov 2020 11:34:45 +0600 Subject: [PATCH 1/3] start 0.3.2 --- CHANGELOG.md | 5 +++++ gradle.properties | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8649aa41f8..907add6213a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.3.2 + +* `Versions`: + * `Coroutines`: `1.4.1` -> `1.4.2` + ## 0.3.1 **ANDROID PACKAGES** diff --git a/gradle.properties b/gradle.properties index 22e751c045b..7e3b86a25a2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ kotlin_coroutines_version=1.4.1 kotlin_serialisation_core_version=1.0.1 kotlin_exposed_version=0.28.1 -ktor_version=1.4.1 +ktor_version=1.4.2 klockVersion=1.12.1 @@ -41,5 +41,5 @@ dokka_version=1.4.0 # Project data group=dev.inmo -version=0.3.1 -android_code_version=1 +version=0.3.2 +android_code_version=2 From e20929aec44e6cf535ba56833708175e2a7a1968 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 11 Nov 2020 12:03:14 +0600 Subject: [PATCH 2/3] mappers workaround --- CHANGELOG.md | 4 ++++ .../dev/inmo/micro_utils/repos/MapperRepo.kt | 14 +++++++++++++- .../repos/mappers/KeyValueMappers.kt | 17 ++++++++++++++++- .../repos/mappers/OneToManyKeyValueMappers.kt | 15 +++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 907add6213a..45dcb68db3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ * `Versions`: * `Coroutines`: `1.4.1` -> `1.4.2` +* `Repos`: + * `Common`: + * New inline function `mapper` for simplier creating of `MapperRepo` objects + * Extensions `withMapper` for keyvalue repos and onetomany repos ## 0.3.1 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 334077a007f..3d25d74ee2a 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 @@ -6,4 +6,16 @@ interface MapperRepo { suspend fun ToKey.toInnerKey() = this as FromKey suspend fun ToValue.toInnerValue() = this as FromValue -} \ No newline at end of file +} + +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 { + 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() +} 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 75d4f860079..cf727a024ec 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 @@ -51,7 +51,12 @@ open class MapperReadStandardKeyValueRepo( override suspend fun count(): Long = to.count() } -open class MapperWriteStandardKeyValueRepo( +@Suppress("NOTHING_TO_INLINE") +inline fun ReadStandardKeyValueRepo.withMapper( + mapper: MapperRepo +): ReadStandardKeyValueRepo = MapperReadStandardKeyValueRepo(this, mapper) + + open class MapperWriteStandardKeyValueRepo( private val to: WriteStandardKeyValueRepo, mapper: MapperRepo ) : WriteStandardKeyValueRepo, MapperRepo by mapper { @@ -75,6 +80,11 @@ open class MapperWriteStandardKeyValueRepo( ) } +@Suppress("NOTHING_TO_INLINE") +inline fun WriteStandardKeyValueRepo.withMapper( + mapper: MapperRepo +): WriteStandardKeyValueRepo = MapperWriteStandardKeyValueRepo(this, mapper) + open class MapperStandardKeyValueRepo( private val to: StandardKeyValueRepo, mapper: MapperRepo @@ -82,3 +92,8 @@ open class MapperStandardKeyValueRepo( MapperRepo by mapper, ReadStandardKeyValueRepo by MapperReadStandardKeyValueRepo(to, mapper), WriteStandardKeyValueRepo by MapperWriteStandardKeyValueRepo(to, mapper) + +@Suppress("NOTHING_TO_INLINE") +inline fun StandardKeyValueRepo.withMapper( + mapper: MapperRepo +): StandardKeyValueRepo = MapperStandardKeyValueRepo(this, mapper) 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 37c1602b203..b3fbddd9db7 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 @@ -49,6 +49,11 @@ open class MapperReadOneToManyKeyValueRepo( override suspend fun count(k: FromKey): Long = to.count(k.toOutKey()) } +@Suppress("NOTHING_TO_INLINE") +inline fun ReadOneToManyKeyValueRepo.withMapper( + mapper: MapperRepo +): ReadOneToManyKeyValueRepo = MapperReadOneToManyKeyValueRepo(this, mapper) + open class MapperWriteOneToManyKeyValueRepo( private val to: WriteOneToManyKeyValueRepo, mapper: MapperRepo @@ -78,6 +83,11 @@ open class MapperWriteOneToManyKeyValueRepo( override suspend fun clear(k: FromKey) = to.clear(k.toOutKey()) } +@Suppress("NOTHING_TO_INLINE") +inline fun WriteOneToManyKeyValueRepo.withMapper( + mapper: MapperRepo +): WriteOneToManyKeyValueRepo = MapperWriteOneToManyKeyValueRepo(this, mapper) + open class MapperOneToManyKeyValueRepo( private val to: OneToManyKeyValueRepo, mapper: MapperRepo @@ -85,3 +95,8 @@ open class MapperOneToManyKeyValueRepo( MapperRepo by mapper, ReadOneToManyKeyValueRepo by MapperReadOneToManyKeyValueRepo(to, mapper), WriteOneToManyKeyValueRepo by MapperWriteOneToManyKeyValueRepo(to, mapper) + +@Suppress("NOTHING_TO_INLINE") +inline fun OneToManyKeyValueRepo.withMapper( + mapper: MapperRepo +): OneToManyKeyValueRepo = MapperOneToManyKeyValueRepo(this, mapper) From b7d0ce3c975a2b87b8b50b1fbdd8efc4a9622809 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 11 Nov 2020 12:04:47 +0600 Subject: [PATCH 3/3] formatting fix in keyvalue --- .../dev/inmo/micro_utils/repos/mappers/KeyValueMappers.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cf727a024ec..6a770683a4d 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 @@ -56,7 +56,7 @@ inline fun ReadStandardKeyValueRepo ): ReadStandardKeyValueRepo = MapperReadStandardKeyValueRepo(this, mapper) - open class MapperWriteStandardKeyValueRepo( +open class MapperWriteStandardKeyValueRepo( private val to: WriteStandardKeyValueRepo, mapper: MapperRepo ) : WriteStandardKeyValueRepo, MapperRepo by mapper {