diff options
Diffstat (limited to 'core/src/main/kotlin/links/DRI.kt')
-rw-r--r-- | core/src/main/kotlin/links/DRI.kt | 21 |
1 files changed, 21 insertions, 0 deletions
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<EnumEntryDRIExtra>() + +abstract class DRIExtraProperty<T> { + 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<String, Any> = if (data != null) ObjectMapper().readValue(data) else mutableMapOf() + inline operator fun <reified T> get(prop: DRIExtraProperty<T>): T? = + map[prop.key]?.let { prop as? T } + + inline operator fun <reified T> set(prop: DRIExtraProperty<T>, 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") |