From 5f8d822e2376afe18c1a2f64a57d1e19d9391333 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 24 Feb 2020 12:38:17 +0100 Subject: Adds property merging strategies --- core/src/main/kotlin/model/properties/properties.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'core') 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 { - interface Key + interface Key { + fun mergeStrategyFor(left: T, right: T): MergeStrategy = MergeStrategy.Fail { + throw NotImplementedError("Property merging for $this is not implemented") + } + } val key: Key } interface CalculatedProperty: Property.Key { fun calculate(subject: C): T -} \ No newline at end of file +} + +sealed class MergeStrategy { + class Replace(val newProperty: Property): MergeStrategy() + object Remove: MergeStrategy() + class Full(val merger: (preMerged: C, left: C, right: C) -> C): MergeStrategy() + class Fail(val error: () -> Nothing): MergeStrategy() +} -- cgit