mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-17 14:29:24 +00:00
Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
39135a4000 | |||
eaa014cebd | |||
856e657f81 | |||
3a609e5b66 | |||
d0022dd599 | |||
7ba6eed453 | |||
beeb6ecc0a | |||
7cdc17a714 | |||
4765a950a9 | |||
65e8137e08 | |||
ae546dd9ad | |||
8110c42be0 | |||
bd2b5ae5fc | |||
2ddfffa6a9 | |||
a4b54e861d | |||
c6785f1a4f | |||
83fe621c56 | |||
b3a93e17eb | |||
546a391af3 | |||
786cf9bd8b | |||
dfd6fe062d | |||
b6ef818613 |
42
CHANGELOG.md
42
CHANGELOG.md
@@ -1,5 +1,47 @@
|
||||
# Changelog
|
||||
|
||||
## 0.19.8
|
||||
|
||||
* `Versions`:
|
||||
* `Coroutines`: `1.7.2` -> `1.7.3`
|
||||
* `Kotlin`: `1.8.20` -> `1.8.22`
|
||||
* `Compose`: `1.4.1` -> `1.4.3`
|
||||
* `Okio`: `3.3.0` -> `3.4.0`
|
||||
* `RecyclerView`: `1.3.0` -> `1.3.1`
|
||||
* `Fragment`: `1.6.0` -> `1.6.1`
|
||||
* `Repos`:
|
||||
* Fixes In `KeyValueRepo.clear()` of almost all inheritors of `KeyValueRepo`
|
||||
* `Cache`:
|
||||
* All full caches got `skipStartInvalidate` property. By default, this property is `false` and fully caching repos
|
||||
will be automatically invalidated on start of their work
|
||||
|
||||
## 0.19.7
|
||||
|
||||
* `Versions`:
|
||||
* `Coroutines`: `1.7.1` -> `1.7.2`
|
||||
|
||||
## 0.19.6
|
||||
|
||||
* `Versions`:
|
||||
* `Coroutines`: `1.6.4` -> `1.7.1`
|
||||
* `Ktor`: `2.3.1` -> `2.3.2`
|
||||
* `Compose`: `1.4.0` -> `1.4.1`
|
||||
|
||||
## 0.19.5
|
||||
|
||||
* `Repos`:
|
||||
* `Generator`:
|
||||
* Fixes in new type generation
|
||||
|
||||
## 0.19.4
|
||||
|
||||
* `Versions`:
|
||||
* `Koin`: `3.4.1` -> `3.4.2`
|
||||
* `Android Fragments`: `1.5.7` -> `1.6.0`
|
||||
* `Koin`
|
||||
* `Generator`
|
||||
* Fixes in new generic generator part
|
||||
|
||||
## 0.19.3
|
||||
|
||||
* `Koin`
|
||||
|
@@ -17,6 +17,10 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.versions)
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
@@ -38,3 +42,4 @@ allprojects {
|
||||
|
||||
apply from: "./extensions.gradle"
|
||||
apply from: "./github_release.gradle"
|
||||
apply from: "./versions_plugin_setup.gradle"
|
||||
|
@@ -14,5 +14,5 @@ crypto_js_version=4.1.1
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.19.3
|
||||
android_code_version=199
|
||||
version=0.19.8
|
||||
android_code_version=204
|
||||
|
@@ -1,36 +1,38 @@
|
||||
[versions]
|
||||
|
||||
kt = "1.8.20"
|
||||
kt = "1.8.22"
|
||||
kt-serialization = "1.5.1"
|
||||
kt-coroutines = "1.6.4"
|
||||
kt-coroutines = "1.7.3"
|
||||
|
||||
kslog = "1.1.1"
|
||||
|
||||
jb-compose = "1.4.0"
|
||||
jb-compose = "1.4.3"
|
||||
jb-exposed = "0.41.1"
|
||||
jb-dokka = "1.8.20"
|
||||
|
||||
korlibs = "4.0.3"
|
||||
uuid = "0.7.1"
|
||||
|
||||
ktor = "2.3.1"
|
||||
ktor = "2.3.2"
|
||||
|
||||
gh-release = "2.4.1"
|
||||
|
||||
koin = "3.4.1"
|
||||
koin = "3.4.2"
|
||||
|
||||
okio = "3.3.0"
|
||||
okio = "3.4.0"
|
||||
|
||||
ksp = "1.8.20-1.0.11"
|
||||
ksp = "1.8.22-1.0.11"
|
||||
kotlin-poet = "1.14.2"
|
||||
|
||||
versions = "0.47.0"
|
||||
|
||||
android-gradle = "7.4.2"
|
||||
dexcount = "4.0.0"
|
||||
|
||||
android-coreKtx = "1.10.1"
|
||||
android-recyclerView = "1.3.0"
|
||||
android-recyclerView = "1.3.1"
|
||||
android-appCompat = "1.6.1"
|
||||
android-fragment = "1.5.7"
|
||||
android-fragment = "1.6.1"
|
||||
android-espresso = "3.5.1"
|
||||
android-test = "1.1.5"
|
||||
|
||||
@@ -109,3 +111,5 @@ buildscript-android-dexcount = { module = "com.getkeepsafe.dexcount:dexcount-gra
|
||||
[plugins]
|
||||
|
||||
jb-compose = { id = "org.jetbrains.compose", version.ref = "jb-compose" }
|
||||
|
||||
versions = { id = "com.github.ben-manes.versions", version.ref = "versions" }
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@@ -13,3 +13,8 @@ dependencies {
|
||||
api libs.kotlin.poet
|
||||
api libs.ksp
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
@@ -127,7 +127,7 @@ class Processor(
|
||||
addModifiers(KModifier.INLINE)
|
||||
targetTypeAsGenericType ?.let {
|
||||
addTypeVariable(it)
|
||||
returns(it)
|
||||
returns(it.copy(nullable = nullable))
|
||||
} ?: returns(targetType)
|
||||
addCode(
|
||||
"return " + (if (nullable) {
|
||||
|
@@ -97,3 +97,28 @@ public inline fun <reified T : Any> Module.singleTest(createdAtStart: Boolean =
|
||||
*/
|
||||
public inline fun <reified T : Any> Module.factoryTest(noinline definition: Definition<T>):
|
||||
KoinDefinition<T> = factory(named("test"), definition = definition)
|
||||
|
||||
/**
|
||||
* @return Definition by key "testNullable" with [parameters]
|
||||
*/
|
||||
public inline fun <reified T : Any> Scope.testNullable(noinline parameters: ParametersDefinition? =
|
||||
null): T? = getOrNull(named("testNullable"), parameters)
|
||||
|
||||
/**
|
||||
* @return Definition by key "testNullable" with [parameters]
|
||||
*/
|
||||
public inline fun <reified T : Any> Koin.testNullable(noinline parameters: ParametersDefinition? =
|
||||
null): T? = getOrNull(named("testNullable"), parameters)
|
||||
|
||||
/**
|
||||
* Will register [definition] with [org.koin.core.module.Module.single] and key "testNullable"
|
||||
*/
|
||||
public inline fun <reified T : Any> Module.singleTestNullable(createdAtStart: Boolean = false,
|
||||
noinline definition: Definition<T>): KoinDefinition<T> = single(named("testNullable"),
|
||||
createdAtStart = createdAtStart, definition = definition)
|
||||
|
||||
/**
|
||||
* Will register [definition] with [org.koin.core.module.Module.factory] and key "testNullable"
|
||||
*/
|
||||
public inline fun <reified T : Any> Module.factoryTestNullable(noinline definition: Definition<T>):
|
||||
KoinDefinition<T> = factory(named("testNullable"), definition = definition)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
@file:GenerateKoinDefinition("sampleInfo", Test::class, String::class, nullable = false)
|
||||
@file:GenerateGenericKoinDefinition("test", nullable = false)
|
||||
@file:GenerateGenericKoinDefinition("testNullable", nullable = true)
|
||||
package dev.inmo.micro_utils.koin.generator.test
|
||||
|
||||
import dev.inmo.micro_utils.koin.annotations.GenerateGenericKoinDefinition
|
||||
|
@@ -38,7 +38,7 @@ fun <Key, Value> ReadKeyValueRepo<Key, Value>.cached(
|
||||
) = ReadKeyValueCacheRepo(this, kvCache)
|
||||
|
||||
open class KeyValueCacheRepo<Key,Value>(
|
||||
parentRepo: KeyValueRepo<Key, Value>,
|
||||
override val parentRepo: KeyValueRepo<Key, Value>,
|
||||
kvCache: KVCache<Key, Value>,
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||
) : ReadKeyValueCacheRepo<Key,Value>(parentRepo, kvCache), KeyValueRepo<Key,Value>, WriteKeyValueRepo<Key, Value> by parentRepo, CommonCacheRepo {
|
||||
@@ -46,6 +46,11 @@ open class KeyValueCacheRepo<Key,Value>(
|
||||
protected val onRemoveJob = parentRepo.onValueRemoved.onEach { kvCache.unset(it) }.launchIn(scope)
|
||||
|
||||
override suspend fun invalidate() = kvCache.clear()
|
||||
|
||||
override suspend fun clear() {
|
||||
parentRepo.clear()
|
||||
kvCache.clear()
|
||||
}
|
||||
}
|
||||
|
||||
fun <Key, Value> KeyValueRepo<Key, Value>.cached(
|
||||
|
@@ -21,6 +21,12 @@ open class SimpleFullKVCache<K, V>(
|
||||
kvParent.unset(toUnset)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun clear() {
|
||||
syncMutex.withLock {
|
||||
kvParent.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <K, V> FullKVCache(
|
||||
|
@@ -37,6 +37,10 @@ open class SimpleKVCache<K, V>(
|
||||
override suspend fun unset(toUnset: List<K>) {
|
||||
syncMutex.withLock { makeUnset(toUnset) }
|
||||
}
|
||||
|
||||
override suspend fun clear() {
|
||||
syncMutex.withLock { makeUnset(cacheQueue) }
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <K, V> KVCache(
|
||||
|
@@ -39,4 +39,9 @@ open class AutoRecacheKeyValueRepo<Id, RegisteredObject>(
|
||||
).also {
|
||||
kvCache.unsetWithValues(toUnset)
|
||||
}
|
||||
|
||||
override suspend fun clear() {
|
||||
originalRepo.clear()
|
||||
kvCache.clear()
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.micro_utils.repos.cache.full
|
||||
|
||||
import dev.inmo.micro_utils.common.*
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.pagination.Pagination
|
||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
@@ -84,6 +85,7 @@ open class FullCRUDCacheRepo<ObjectType, IdType, InputValueType>(
|
||||
override val parentRepo: CRUDRepo<ObjectType, IdType, InputValueType>,
|
||||
kvCache: FullKVCache<IdType, ObjectType>,
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||
skipStartInvalidate: Boolean = false,
|
||||
idGetter: (ObjectType) -> IdType
|
||||
) : FullReadCRUDCacheRepo<ObjectType, IdType>(
|
||||
parentRepo,
|
||||
@@ -97,6 +99,12 @@ open class FullCRUDCacheRepo<ObjectType, IdType, InputValueType>(
|
||||
idGetter
|
||||
),
|
||||
CRUDRepo<ObjectType, IdType, InputValueType> {
|
||||
init {
|
||||
if (!skipStartInvalidate) {
|
||||
scope.launchSafelyWithoutExceptions { invalidate() }
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun invalidate() {
|
||||
actualizeAll()
|
||||
}
|
||||
@@ -105,12 +113,14 @@ open class FullCRUDCacheRepo<ObjectType, IdType, InputValueType>(
|
||||
fun <ObjectType, IdType, InputType> CRUDRepo<ObjectType, IdType, InputType>.fullyCached(
|
||||
kvCache: FullKVCache<IdType, ObjectType> = FullKVCache(),
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||
skipStartInvalidate: Boolean = false,
|
||||
idGetter: (ObjectType) -> IdType
|
||||
) = FullCRUDCacheRepo(this, kvCache, scope, idGetter)
|
||||
) = FullCRUDCacheRepo(this, kvCache, scope, skipStartInvalidate, idGetter)
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("this.fullyCached(kvCache, scope, idGetter)", "dev.inmo.micro_utils.repos.cache.full.fullyCached"))
|
||||
fun <ObjectType, IdType, InputType> CRUDRepo<ObjectType, IdType, InputType>.cached(
|
||||
kvCache: FullKVCache<IdType, ObjectType>,
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||
skipStartInvalidate: Boolean = false,
|
||||
idGetter: (ObjectType) -> IdType
|
||||
) = fullyCached(kvCache, scope, idGetter)
|
||||
) = fullyCached(kvCache, scope, skipStartInvalidate, idGetter)
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.micro_utils.repos.cache.full
|
||||
|
||||
import dev.inmo.micro_utils.common.*
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.pagination.Pagination
|
||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
@@ -106,15 +107,30 @@ fun <Key, Value> WriteKeyValueRepo<Key, Value>.caching(
|
||||
open class FullKeyValueCacheRepo<Key,Value>(
|
||||
protected open val parentRepo: KeyValueRepo<Key, Value>,
|
||||
kvCache: FullKVCache<Key, Value>,
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||
skipStartInvalidate: Boolean = false
|
||||
) : FullWriteKeyValueCacheRepo<Key,Value>(parentRepo, kvCache, scope),
|
||||
KeyValueRepo<Key,Value>,
|
||||
ReadKeyValueRepo<Key, Value> by FullReadKeyValueCacheRepo(parentRepo, kvCache) {
|
||||
ReadKeyValueRepo<Key, Value> by FullReadKeyValueCacheRepo(
|
||||
parentRepo,
|
||||
kvCache
|
||||
) {
|
||||
init {
|
||||
if (!skipStartInvalidate) {
|
||||
scope.launchSafelyWithoutExceptions { invalidate() }
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun unsetWithValues(toUnset: List<Value>) = parentRepo.unsetWithValues(toUnset)
|
||||
|
||||
override suspend fun invalidate() {
|
||||
kvCache.actualizeAll(parentRepo)
|
||||
}
|
||||
|
||||
override suspend fun clear() {
|
||||
parentRepo.clear()
|
||||
kvCache.clear()
|
||||
}
|
||||
}
|
||||
|
||||
fun <Key, Value> KeyValueRepo<Key, Value>.fullyCached(
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.micro_utils.repos.cache.full
|
||||
|
||||
import dev.inmo.micro_utils.common.*
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.pagination.utils.*
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
@@ -142,10 +143,17 @@ fun <Key, Value> WriteKeyValuesRepo<Key, Value>.caching(
|
||||
open class FullKeyValuesCacheRepo<Key,Value>(
|
||||
protected open val parentRepo: KeyValuesRepo<Key, Value>,
|
||||
kvCache: FullKVCache<Key, List<Value>>,
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||
skipStartInvalidate: Boolean = false
|
||||
) : FullWriteKeyValuesCacheRepo<Key, Value>(parentRepo, kvCache, scope),
|
||||
KeyValuesRepo<Key, Value>,
|
||||
ReadKeyValuesRepo<Key, Value> by FullReadKeyValuesCacheRepo(parentRepo, kvCache) {
|
||||
init {
|
||||
if (!skipStartInvalidate) {
|
||||
scope.launchSafelyWithoutExceptions { invalidate() }
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun clearWithValue(v: Value) {
|
||||
doAllWithCurrentPaging {
|
||||
keys(v, it).also {
|
||||
|
@@ -127,7 +127,11 @@ open class MapperKeyValueRepo<FromKey, FromValue, ToKey, ToValue>(
|
||||
) : KeyValueRepo<FromKey, FromValue>,
|
||||
MapperRepo<FromKey, FromValue, ToKey, ToValue> by mapper,
|
||||
ReadKeyValueRepo<FromKey, FromValue> by MapperReadKeyValueRepo(to, mapper),
|
||||
WriteKeyValueRepo<FromKey, FromValue> by MapperWriteKeyValueRepo(to, mapper)
|
||||
WriteKeyValueRepo<FromKey, FromValue> by MapperWriteKeyValueRepo(to, mapper) {
|
||||
override suspend fun clear() {
|
||||
to.clear()
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun <FromKey, FromValue, ToKey, ToValue> KeyValueRepo<ToKey, ToValue>.withMapper(
|
||||
|
@@ -202,9 +202,14 @@ class FileWriteKeyValueRepo(
|
||||
@Warning("Files watching will not correctly works on Android Platform with version of API lower than API 26")
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE")
|
||||
class FileKeyValueRepo(
|
||||
folder: File,
|
||||
private val folder: File,
|
||||
filesChangedProcessingScope: CoroutineScope? = null
|
||||
) : KeyValueRepo<String, File>,
|
||||
WriteKeyValueRepo<String, File> by FileWriteKeyValueRepo(folder, filesChangedProcessingScope),
|
||||
ReadKeyValueRepo<String, File> by FileReadKeyValueRepo(folder) {
|
||||
override suspend fun clear() {
|
||||
withContext(Dispatchers.IO) {
|
||||
folder.listFiles() ?.forEach { runCatching { it.deleteRecursively() } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.pagination.utils.paginate
|
||||
import dev.inmo.micro_utils.pagination.utils.reverse
|
||||
import dev.inmo.micro_utils.repos.KeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.pagination.maxPagePagination
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
private val cache = HashMap<String, KeyValueStore<*>>()
|
||||
@@ -159,6 +160,24 @@ class KeyValueStore<T : Any> internal constructor (
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun clear() {
|
||||
val keys = mutableSetOf<String>()
|
||||
doWithPagination(maxPagePagination()) {
|
||||
keys(it).also {
|
||||
keys.addAll(it.results)
|
||||
}.nextPageIfNotEmpty()
|
||||
}
|
||||
val success = sharedPreferences.edit().apply {
|
||||
clear()
|
||||
}.commit()
|
||||
|
||||
if (success) {
|
||||
keys.forEach {
|
||||
_onValueRemovedFlow.emit(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
operator fun <T : Any> invoke(
|
||||
context: Context,
|
||||
|
@@ -73,4 +73,18 @@ abstract class AbstractExposedKeyValueRepo<Key, Value>(
|
||||
_onValueRemoved.emit(it)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun clear() {
|
||||
transaction(database) {
|
||||
val keys = selectAll().map { it.asKey }
|
||||
|
||||
deleteAll()
|
||||
|
||||
keys
|
||||
}.also {
|
||||
it.forEach {
|
||||
_onValueRemoved.emit(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import kotlinx.coroutines.flow.*
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.inList
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.inSubQuery
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
open class ExposedKeyValueRepo<Key, Value>(
|
||||
@@ -72,4 +73,18 @@ open class ExposedKeyValueRepo<Key, Value>(
|
||||
_onValueRemoved.emit(it)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun clear() {
|
||||
transaction(database) {
|
||||
val keys = selectAll().map { it.asKey }
|
||||
|
||||
deleteAll()
|
||||
|
||||
keys
|
||||
}.also {
|
||||
it.forEach {
|
||||
_onValueRemoved.emit(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,3 +14,8 @@ dependencies {
|
||||
api libs.kotlin.poet
|
||||
api libs.ksp
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
@@ -100,7 +100,11 @@ class Processor(
|
||||
primaryConstructor(
|
||||
FunSpec.constructorBuilder().apply {
|
||||
ksClassProperties.forEach {
|
||||
addParameter(it.simpleName.getShortName(), it.typeName)
|
||||
addParameter(
|
||||
ParameterSpec.builder(it.simpleName.getShortName(), it.typeName).apply {
|
||||
annotations += it.annotations.map { it.toAnnotationSpec() }
|
||||
}.build()
|
||||
)
|
||||
typeBuilder.addProperty(
|
||||
PropertySpec.builder(it.simpleName.getShortName(), it.typeName, KModifier.OVERRIDE).apply {
|
||||
initializer(it.simpleName.getShortName())
|
||||
|
@@ -11,18 +11,20 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
@SerialName(value = "NewTest")
|
||||
public data class NewTest(
|
||||
public override val property1: String,
|
||||
public override val property2: Int,
|
||||
public override val parent: ParentTypeId?,
|
||||
override val property1: String,
|
||||
override val property2: Int,
|
||||
@Serializable
|
||||
override val parent: ParentTypeId?,
|
||||
) : Test
|
||||
|
||||
@Serializable
|
||||
@SerialName(value = "RegisteredTest")
|
||||
public data class RegisteredTest(
|
||||
public override val id: TestId,
|
||||
public override val property1: String,
|
||||
public override val property2: Int,
|
||||
public override val parent: ParentTypeId?,
|
||||
override val id: TestId,
|
||||
override val property1: String,
|
||||
override val property2: Int,
|
||||
@Serializable
|
||||
override val parent: ParentTypeId?,
|
||||
) : Test, IRegisteredTest
|
||||
|
||||
public fun Test.asNew(): NewTest = NewTest(property1, property2, parent)
|
||||
|
@@ -17,6 +17,7 @@ typealias ParentTypeId = TestId
|
||||
sealed interface Test {
|
||||
val property1: String
|
||||
val property2: Int
|
||||
@Serializable
|
||||
val parent: ParentTypeId?
|
||||
|
||||
@GenerateCRUDModelExcludeOverride
|
||||
|
@@ -94,6 +94,10 @@ class MapKeyValueRepo<Key, Value>(
|
||||
private val map: MutableMap<Key, Value> = mutableMapOf()
|
||||
) : KeyValueRepo<Key, Value>,
|
||||
ReadKeyValueRepo<Key, Value> by ReadMapKeyValueRepo(map),
|
||||
WriteKeyValueRepo<Key, Value> by WriteMapKeyValueRepo(map)
|
||||
WriteKeyValueRepo<Key, Value> by WriteMapKeyValueRepo(map) {
|
||||
override suspend fun clear() {
|
||||
map.clear()
|
||||
}
|
||||
}
|
||||
|
||||
fun <K, V> MutableMap<K, V>.asKeyValueRepo(): KeyValueRepo<K, V> = MapKeyValueRepo(this)
|
||||
|
11
versions_plugin_setup.gradle
Normal file
11
versions_plugin_setup.gradle
Normal file
@@ -0,0 +1,11 @@
|
||||
def isNonStable = { String version ->
|
||||
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
|
||||
def regex = /^[0-9,.v-]+(-r)?$/
|
||||
return !stableKeyword && !(version ==~ regex)
|
||||
}
|
||||
|
||||
tasks.named("dependencyUpdates").configure {
|
||||
rejectVersionIf {
|
||||
isNonStable(it.candidate.version)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user