From 1ada27414d66e58b19e20a968834356e81dd26b2 Mon Sep 17 00:00:00 2001 From: vmishenev Date: Tue, 21 Sep 2021 21:38:44 +0300 Subject: Fix link to javadoc enum entry (#2131) --- core/src/main/kotlin/links/DRI.kt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'core/src') diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt index 25b9546f..c646934d 100644 --- a/core/src/main/kotlin/links/DRI.kt +++ b/core/src/main/kotlin/links/DRI.kt @@ -1,7 +1,10 @@ package org.jetbrains.dokka.links +import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonTypeInfo import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.CLASS +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue /** * [DRI] stands for DokkaResourceIdentifier @@ -23,6 +26,24 @@ data class DRI( } } +object EnumEntryDRIExtra: DRIExtraProperty() + +abstract class DRIExtraProperty { + val key: String = this::class.qualifiedName + ?: (this.javaClass.let { it.`package`.name + "." + it.simpleName.ifEmpty { "anonymous" } }) +} + +class DRIExtraContainer(val data: String? = null) { + val map: MutableMap = if (data != null) ObjectMapper().readValue(data) else mutableMapOf() + inline operator fun get(prop: DRIExtraProperty): T? = + map[prop.key]?.let { prop as? T } + + inline operator fun set(prop: DRIExtraProperty, value: T) = + value.also { map[prop.key] = it as Any } + + fun encode(): String = ObjectMapper().writeValueAsString(map) +} + val DriOfUnit = DRI("kotlin", "Unit") val DriOfAny = DRI("kotlin", "Any") -- cgit