From c4a543c18a8285a2a8be1edee1c725a27bffe4cb Mon Sep 17 00:00:00 2001 From: Paul Kraft Date: Sat, 9 Nov 2024 15:43:02 -0800 Subject: [PATCH] Readd uuid property --- .../knowledgesource/KnowledgeSource.kt | 9 ++++++++- .../spezi/core/utils/SharedRepositoryTest.kt | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/core/utils/src/main/kotlin/edu/stanford/spezi/core/utils/foundation/knowledgesource/KnowledgeSource.kt b/core/utils/src/main/kotlin/edu/stanford/spezi/core/utils/foundation/knowledgesource/KnowledgeSource.kt index 35dff4652..e01160fe4 100644 --- a/core/utils/src/main/kotlin/edu/stanford/spezi/core/utils/foundation/knowledgesource/KnowledgeSource.kt +++ b/core/utils/src/main/kotlin/edu/stanford/spezi/core/utils/foundation/knowledgesource/KnowledgeSource.kt @@ -1,5 +1,12 @@ package edu.stanford.spezi.core.utils.foundation.knowledgesource import edu.stanford.spezi.core.utils.foundation.RepositoryAnchor +import java.util.UUID -interface KnowledgeSource +interface KnowledgeSource { + @Suppress("detekt:VariableMinLength") + val uuid: UUID + + fun isEqualTo(other: KnowledgeSource): Boolean = + uuid == other.uuid +} diff --git a/core/utils/src/test/kotlin/edu/stanford/spezi/core/utils/SharedRepositoryTest.kt b/core/utils/src/test/kotlin/edu/stanford/spezi/core/utils/SharedRepositoryTest.kt index ad2c6a095..dbb18d79f 100644 --- a/core/utils/src/test/kotlin/edu/stanford/spezi/core/utils/SharedRepositoryTest.kt +++ b/core/utils/src/test/kotlin/edu/stanford/spezi/core/utils/SharedRepositoryTest.kt @@ -19,7 +19,9 @@ interface TestTypes { data class TestDataClass(override var value: Int) : TestTypes { companion object { - val key = object : KnowledgeSource {} + val key = object : KnowledgeSource { + override val uuid = UUID() + } } } @@ -34,15 +36,20 @@ class TestClass(override val value: Int) : TestTypes { } companion object { - val key = object : KnowledgeSource {} + val key = object : KnowledgeSource { + override val uuid = UUID() + } } } -object KeyLike : KnowledgeSource +object KeyLike : KnowledgeSource { + override val uuid = UUID() +} data class DefaultedTestDataClass(override val value: Int) : TestTypes { companion object { val key = object : DefaultProvidingKnowledgeSource { + override val uuid = UUID() override val defaultValue get() = DefaultedTestDataClass(0) } } @@ -55,6 +62,7 @@ data class ComputedTestDataClass(override val value: Int) : TestTypes { ComputedTestDataClass, SharedRepository > { + override val uuid = UUID() override val storagePolicy: ComputedKnowledgeSourceStoragePolicy = ComputedKnowledgeSourceStoragePolicy.AlwaysCompute override fun compute(repository: SharedRepository) = @@ -66,6 +74,7 @@ data class ComputedTestDataClass(override val value: Int) : TestTypes { ComputedTestDataClass, SharedRepository > { + override val uuid = UUID() override val storagePolicy: ComputedKnowledgeSourceStoragePolicy = ComputedKnowledgeSourceStoragePolicy.Store override fun compute(repository: SharedRepository) = @@ -81,6 +90,7 @@ data class OptionalComputedTestDataClass(override val value: Int) : TestTypes { OptionalComputedTestDataClass, SharedRepository > { + override val uuid = UUID() override val storagePolicy: ComputedKnowledgeSourceStoragePolicy = ComputedKnowledgeSourceStoragePolicy.AlwaysCompute override fun compute(repository: SharedRepository): OptionalComputedTestDataClass? = @@ -92,6 +102,7 @@ data class OptionalComputedTestDataClass(override val value: Int) : TestTypes { OptionalComputedTestDataClass, SharedRepository > { + override val uuid = UUID() override val storagePolicy: ComputedKnowledgeSourceStoragePolicy = ComputedKnowledgeSourceStoragePolicy.Store override fun compute(repository: SharedRepository): OptionalComputedTestDataClass? =