mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-10-05 15:19:27 +00:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
f6a06ee8ea | |||
2644f27975 | |||
3dc68a7b8b | |||
97fc1d6239 | |||
662f4d22a3 | |||
b70aa12be9 | |||
71f12f5f19 | |||
e10504eeeb | |||
2dea9f3bc0 | |||
35c9dda5bc | |||
e831f3949a | |||
b0b39cc693 | |||
fc03be3f73 | |||
b61f6b81f1 | |||
f5bc1c1fce | |||
a729f9568c | |||
5749e00377 | |||
ef73c24a0c | |||
94717ee351 | |||
9a18ded65b |
23
CHANGELOG.md
23
CHANGELOG.md
@@ -1,5 +1,28 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.5.23
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Exposed`: `0.33.1` -> `0.34.1`
|
||||||
|
* `Common`:
|
||||||
|
* New extensions `Iterable#joinTo` and `Array#joinTo`
|
||||||
|
|
||||||
|
## 0.5.22
|
||||||
|
|
||||||
|
* `Versions`
|
||||||
|
* `Kotlin`: `1.5.21` -> `1.5.30`
|
||||||
|
* `Klock`: `2.3.2` -> `2.3.4`
|
||||||
|
* `AppCompat`: `1.3.0` -> `1.3.1`
|
||||||
|
* `Ktor`: `1.6.2` -> `1.6.3`
|
||||||
|
|
||||||
|
## 0.5.21
|
||||||
|
|
||||||
|
* `Versions`
|
||||||
|
* `Klock`: `2.3.1` -> `2.3.2`
|
||||||
|
* `Serialization`
|
||||||
|
* `Typed Serializer`:
|
||||||
|
* `TypedSerializer` Descriptor serial name has been fixed
|
||||||
|
|
||||||
## 0.5.20
|
## 0.5.20
|
||||||
|
|
||||||
* `Repos`:
|
* `Repos`:
|
||||||
|
@@ -12,9 +12,7 @@ package dev.inmo.micro_utils.common
|
|||||||
AnnotationTarget.PROPERTY_GETTER,
|
AnnotationTarget.PROPERTY_GETTER,
|
||||||
AnnotationTarget.PROPERTY_SETTER,
|
AnnotationTarget.PROPERTY_SETTER,
|
||||||
AnnotationTarget.FUNCTION,
|
AnnotationTarget.FUNCTION,
|
||||||
AnnotationTarget.TYPE,
|
AnnotationTarget.TYPEALIAS
|
||||||
AnnotationTarget.TYPEALIAS,
|
|
||||||
AnnotationTarget.TYPE_PARAMETER
|
|
||||||
)
|
)
|
||||||
annotation class PreviewFeature(val message: String = "It is possible, that behaviour of this thing will be changed or removed in future releases")
|
annotation class PreviewFeature(val message: String = "It is possible, that behaviour of this thing will be changed or removed in future releases")
|
||||||
|
|
||||||
@@ -30,8 +28,6 @@ annotation class PreviewFeature(val message: String = "It is possible, that beha
|
|||||||
AnnotationTarget.PROPERTY_GETTER,
|
AnnotationTarget.PROPERTY_GETTER,
|
||||||
AnnotationTarget.PROPERTY_SETTER,
|
AnnotationTarget.PROPERTY_SETTER,
|
||||||
AnnotationTarget.FUNCTION,
|
AnnotationTarget.FUNCTION,
|
||||||
AnnotationTarget.TYPE,
|
AnnotationTarget.TYPEALIAS
|
||||||
AnnotationTarget.TYPEALIAS,
|
|
||||||
AnnotationTarget.TYPE_PARAMETER
|
|
||||||
)
|
)
|
||||||
annotation class Warning(val message: String)
|
annotation class Warning(val message: String)
|
||||||
|
@@ -0,0 +1,59 @@
|
|||||||
|
package dev.inmo.micro_utils.common
|
||||||
|
|
||||||
|
inline fun <I, R> Iterable<I>.joinTo(
|
||||||
|
crossinline separatorFun: (I) -> R?,
|
||||||
|
prefix: R? = null,
|
||||||
|
postfix: R? = null,
|
||||||
|
crossinline transform: (I) -> R?
|
||||||
|
): List<R> {
|
||||||
|
val result = mutableListOf<R>()
|
||||||
|
val iterator = iterator()
|
||||||
|
|
||||||
|
prefix ?.let(result::add)
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
val element = iterator.next()
|
||||||
|
result.add(transform(element) ?: continue)
|
||||||
|
|
||||||
|
if (iterator.hasNext()) {
|
||||||
|
result.add(separatorFun(element) ?: continue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
postfix ?.let(result::add)
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <I, R> Iterable<I>.joinTo(
|
||||||
|
separator: R? = null,
|
||||||
|
prefix: R? = null,
|
||||||
|
postfix: R? = null,
|
||||||
|
crossinline transform: (I) -> R?
|
||||||
|
): List<R> = joinTo({ separator }, prefix, postfix, transform)
|
||||||
|
|
||||||
|
inline fun <I> Iterable<I>.joinTo(
|
||||||
|
crossinline separatorFun: (I) -> I?,
|
||||||
|
prefix: I? = null,
|
||||||
|
postfix: I? = null
|
||||||
|
): List<I> = joinTo<I, I>(separatorFun, prefix, postfix) { it }
|
||||||
|
|
||||||
|
inline fun <I> Iterable<I>.joinTo(
|
||||||
|
separator: I? = null,
|
||||||
|
prefix: I? = null,
|
||||||
|
postfix: I? = null
|
||||||
|
): List<I> = joinTo<I>({ separator }, prefix, postfix)
|
||||||
|
|
||||||
|
inline fun <I, reified R> Array<I>.joinTo(
|
||||||
|
crossinline separatorFun: (I) -> R?,
|
||||||
|
prefix: R? = null,
|
||||||
|
postfix: R? = null,
|
||||||
|
crossinline transform: (I) -> R?
|
||||||
|
): Array<R> = asIterable().joinTo(separatorFun, prefix, postfix, transform).toTypedArray()
|
||||||
|
|
||||||
|
inline fun <I, reified R> Array<I>.joinTo(
|
||||||
|
separator: R? = null,
|
||||||
|
prefix: R? = null,
|
||||||
|
postfix: R? = null,
|
||||||
|
crossinline transform: (I) -> R?
|
||||||
|
): Array<R> = asIterable().joinTo(separator, prefix, postfix, transform).toTypedArray()
|
@@ -11,7 +11,7 @@ class DiffUtilsTests {
|
|||||||
val withIndex = oldList.withIndex()
|
val withIndex = oldList.withIndex()
|
||||||
|
|
||||||
for (count in 1 .. (floor(oldList.size.toFloat() / 2).toInt())) {
|
for (count in 1 .. (floor(oldList.size.toFloat() / 2).toInt())) {
|
||||||
for ((i, v) in withIndex) {
|
for ((i, _) in withIndex) {
|
||||||
if (i + count > oldList.lastIndex) {
|
if (i + count > oldList.lastIndex) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@@ -7,14 +7,14 @@ android.useAndroidX=true
|
|||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
org.gradle.jvmargs=-Xmx2g
|
org.gradle.jvmargs=-Xmx2g
|
||||||
|
|
||||||
kotlin_version=1.5.21
|
kotlin_version=1.5.30
|
||||||
kotlin_coroutines_version=1.5.1
|
kotlin_coroutines_version=1.5.1
|
||||||
kotlin_serialisation_core_version=1.2.2
|
kotlin_serialisation_core_version=1.2.2
|
||||||
kotlin_exposed_version=0.33.1
|
kotlin_exposed_version=0.34.1
|
||||||
|
|
||||||
ktor_version=1.6.2
|
ktor_version=1.6.3
|
||||||
|
|
||||||
klockVersion=2.3.1
|
klockVersion=2.3.4
|
||||||
|
|
||||||
github_release_plugin_version=2.2.12
|
github_release_plugin_version=2.2.12
|
||||||
|
|
||||||
@@ -24,12 +24,12 @@ uuidVersion=0.3.0
|
|||||||
|
|
||||||
core_ktx_version=1.6.0
|
core_ktx_version=1.6.0
|
||||||
androidx_recycler_version=1.2.1
|
androidx_recycler_version=1.2.1
|
||||||
appcompat_version=1.3.0
|
appcompat_version=1.3.1
|
||||||
|
|
||||||
android_minSdkVersion=19
|
android_minSdkVersion=19
|
||||||
android_compileSdkVersion=30
|
android_compileSdkVersion=30
|
||||||
android_buildToolsVersion=30.0.3
|
android_buildToolsVersion=30.0.3
|
||||||
dexcount_version=2.1.0-RC01
|
dexcount_version=3.0.0
|
||||||
junit_version=4.12
|
junit_version=4.12
|
||||||
test_ext_junit_version=1.1.2
|
test_ext_junit_version=1.1.2
|
||||||
espresso_core=3.3.0
|
espresso_core=3.3.0
|
||||||
@@ -45,5 +45,5 @@ dokka_version=1.5.0
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.5.20
|
version=0.5.23
|
||||||
android_code_version=61
|
android_code_version=64
|
||||||
|
@@ -8,11 +8,23 @@ import kotlin.reflect.KClass
|
|||||||
|
|
||||||
open class TypedSerializer<T : Any>(
|
open class TypedSerializer<T : Any>(
|
||||||
kClass: KClass<T>,
|
kClass: KClass<T>,
|
||||||
presetSerializers: Map<String, KSerializer<out T>> = emptyMap()
|
presetSerializers: Map<String, KSerializer<out T>> = emptyMap(),
|
||||||
) : KSerializer<T> {
|
) : KSerializer<T> {
|
||||||
protected val serializers = presetSerializers.toMutableMap()
|
protected val serializers = presetSerializers.toMutableMap()
|
||||||
@InternalSerializationApi
|
@InternalSerializationApi
|
||||||
open override val descriptor: SerialDescriptor = buildSerialDescriptor(
|
override val descriptor: SerialDescriptor = buildSerialDescriptor(
|
||||||
|
"TypedSerializer",
|
||||||
|
SerialKind.CONTEXTUAL
|
||||||
|
) {
|
||||||
|
element("type", String.serializer().descriptor)
|
||||||
|
element("value", ContextualSerializer(kClass).descriptor)
|
||||||
|
}
|
||||||
|
@InternalSerializationApi
|
||||||
|
@Deprecated(
|
||||||
|
"This descriptor was deprecated due to incorrect serial name. You may use it in case something require it, " +
|
||||||
|
"but it is strongly recommended to migrate onto new descriptor"
|
||||||
|
)
|
||||||
|
protected val oldDescriptor: SerialDescriptor = buildSerialDescriptor(
|
||||||
"TextSourceSerializer",
|
"TextSourceSerializer",
|
||||||
SerialKind.CONTEXTUAL
|
SerialKind.CONTEXTUAL
|
||||||
) {
|
) {
|
||||||
|
Reference in New Issue
Block a user