diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e196401dbe..a692feb380a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.20.22 +* `Common`: + * Add opportunity to create own `Diff` with base constructor + ## 0.20.21 * `Resources`: diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt index 4f2f2635ac4..f4c8008223d 100644 --- a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt @@ -27,7 +27,7 @@ private inline fun getObject( * @see calculateDiff */ @Serializable -data class Diff internal constructor( +data class Diff @Warning(warning) constructor( val removed: List<@Serializable(IndexedValueSerializer::class) IndexedValue>, /** * Old-New values pairs @@ -36,6 +36,10 @@ data class Diff internal constructor( val added: List<@Serializable(IndexedValueSerializer::class) IndexedValue> ) { fun isEmpty(): Boolean = removed.isEmpty() && replaced.isEmpty() && added.isEmpty() + + companion object { + private const val warning = "This feature can be changed without any warranties. Use with caution and only in case you know what you are doing" + } } fun emptyDiff(): Diff = Diff(emptyList(), emptyList(), emptyList())