aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/model/properties/properties.kt15
1 files changed, 13 insertions, 2 deletions
diff --git a/core/src/main/kotlin/model/properties/properties.kt b/core/src/main/kotlin/model/properties/properties.kt
index 5ff1305a..4ca44926 100644
--- a/core/src/main/kotlin/model/properties/properties.kt
+++ b/core/src/main/kotlin/model/properties/properties.kt
@@ -1,10 +1,21 @@
package org.jetbrains.dokka.model.properties
interface Property<in C : Any> {
- interface Key<in C: Any, T: Any>
+ interface Key<in C: Any, T: Any> {
+ fun mergeStrategyFor(left: T, right: T): MergeStrategy<C> = MergeStrategy.Fail {
+ throw NotImplementedError("Property merging for $this is not implemented")
+ }
+ }
val key: Key<C, *>
}
interface CalculatedProperty<in C: Any, T: Any>: Property.Key<C, T> {
fun calculate(subject: C): T
-} \ No newline at end of file
+}
+
+sealed class MergeStrategy<in C> {
+ class Replace<in C : Any>(val newProperty: Property<C>): MergeStrategy<C>()
+ object Remove: MergeStrategy<Any>()
+ class Full<C: Any>(val merger: (preMerged: C, left: C, right: C) -> C): MergeStrategy<C>()
+ class Fail(val error: () -> Nothing): MergeStrategy<Any>()
+}