diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-02-24 12:38:17 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-02-27 10:51:51 +0100 |
commit | 5f8d822e2376afe18c1a2f64a57d1e19d9391333 (patch) | |
tree | 93fb0d0d886a8d49e904a4a68b61e9fc00e1f76a /core/src/main/kotlin/model/properties | |
parent | d92f286903efda12acec74cc1b5e99687e5447aa (diff) | |
download | dokka-5f8d822e2376afe18c1a2f64a57d1e19d9391333.tar.gz dokka-5f8d822e2376afe18c1a2f64a57d1e19d9391333.tar.bz2 dokka-5f8d822e2376afe18c1a2f64a57d1e19d9391333.zip |
Adds property merging strategies
Diffstat (limited to 'core/src/main/kotlin/model/properties')
-rw-r--r-- | core/src/main/kotlin/model/properties/properties.kt | 15 |
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>() +} |