Skip to content

Commit

Permalink
Readd uuid property
Browse files Browse the repository at this point in the history
  • Loading branch information
pauljohanneskraft committed Nov 9, 2024
1 parent 5c4ed79 commit c4a543c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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<Anchor : RepositoryAnchor, Value : Any>
interface KnowledgeSource<Anchor : RepositoryAnchor, Value : Any> {
@Suppress("detekt:VariableMinLength")
val uuid: UUID

fun isEqualTo(other: KnowledgeSource<Anchor, Value>): Boolean =
uuid == other.uuid
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ interface TestTypes {

data class TestDataClass(override var value: Int) : TestTypes {
companion object {
val key = object : KnowledgeSource<TestAnchor, TestDataClass> {}
val key = object : KnowledgeSource<TestAnchor, TestDataClass> {
override val uuid = UUID()
}
}
}

Expand All @@ -34,15 +36,20 @@ class TestClass(override val value: Int) : TestTypes {
}

companion object {
val key = object : KnowledgeSource<TestAnchor, TestClass> {}
val key = object : KnowledgeSource<TestAnchor, TestClass> {
override val uuid = UUID()
}
}
}

object KeyLike : KnowledgeSource<TestAnchor, TestClass>
object KeyLike : KnowledgeSource<TestAnchor, TestClass> {
override val uuid = UUID()
}

data class DefaultedTestDataClass(override val value: Int) : TestTypes {
companion object {
val key = object : DefaultProvidingKnowledgeSource<TestAnchor, DefaultedTestDataClass> {
override val uuid = UUID()
override val defaultValue get() = DefaultedTestDataClass(0)
}
}
Expand All @@ -55,6 +62,7 @@ data class ComputedTestDataClass(override val value: Int) : TestTypes {
ComputedTestDataClass,
SharedRepository<TestAnchor>
> {
override val uuid = UUID()
override val storagePolicy: ComputedKnowledgeSourceStoragePolicy =
ComputedKnowledgeSourceStoragePolicy.AlwaysCompute
override fun compute(repository: SharedRepository<TestAnchor>) =
Expand All @@ -66,6 +74,7 @@ data class ComputedTestDataClass(override val value: Int) : TestTypes {
ComputedTestDataClass,
SharedRepository<TestAnchor>
> {
override val uuid = UUID()
override val storagePolicy: ComputedKnowledgeSourceStoragePolicy =
ComputedKnowledgeSourceStoragePolicy.Store
override fun compute(repository: SharedRepository<TestAnchor>) =
Expand All @@ -81,6 +90,7 @@ data class OptionalComputedTestDataClass(override val value: Int) : TestTypes {
OptionalComputedTestDataClass,
SharedRepository<TestAnchor>
> {
override val uuid = UUID()
override val storagePolicy: ComputedKnowledgeSourceStoragePolicy =
ComputedKnowledgeSourceStoragePolicy.AlwaysCompute
override fun compute(repository: SharedRepository<TestAnchor>): OptionalComputedTestDataClass? =
Expand All @@ -92,6 +102,7 @@ data class OptionalComputedTestDataClass(override val value: Int) : TestTypes {
OptionalComputedTestDataClass,
SharedRepository<TestAnchor>
> {
override val uuid = UUID()
override val storagePolicy: ComputedKnowledgeSourceStoragePolicy =
ComputedKnowledgeSourceStoragePolicy.Store
override fun compute(repository: SharedRepository<TestAnchor>): OptionalComputedTestDataClass? =
Expand Down

0 comments on commit c4a543c

Please sign in to comment.