From d1e16a47819509ed645bb93e1a173e0a97025cef Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Wed, 8 Jan 2025 19:25:29 +0100 Subject: build: Move mod to subproject --- .../moe/nea/ledger/utils/telemetry/ContextValue.kt | 70 ---------------------- 1 file changed, 70 deletions(-) delete mode 100644 src/main/kotlin/moe/nea/ledger/utils/telemetry/ContextValue.kt (limited to 'src/main/kotlin/moe/nea/ledger/utils/telemetry/ContextValue.kt') diff --git a/src/main/kotlin/moe/nea/ledger/utils/telemetry/ContextValue.kt b/src/main/kotlin/moe/nea/ledger/utils/telemetry/ContextValue.kt deleted file mode 100644 index b5891fc..0000000 --- a/src/main/kotlin/moe/nea/ledger/utils/telemetry/ContextValue.kt +++ /dev/null @@ -1,70 +0,0 @@ -package moe.nea.ledger.utils.telemetry - -import com.google.gson.JsonElement -import com.google.gson.JsonObject - -interface ContextValue { - companion object { - fun > lazyCollatable(value: () -> Collatable): Collatable { - return LazyCollatable(value) - } - - fun lazy(value: () -> ContextValue): ContextValue { - return object : ContextValue { - val value by kotlin.lazy(value) - override fun serialize(): JsonElement { - return this.value.serialize() - } - } - } - - fun bool(boolean: Boolean): ContextValue { - return BooleanContext(boolean) - } - - fun string(message: String): ContextValue { - return StringContext(message) - } - - fun jsonObject(vararg pairs: Pair): ContextValue { - val obj = JsonObject() - for ((l, r) in pairs) { - obj.add(l, r) - } - return JsonElementContext(obj) - } - - fun compound(vararg pairs: Pair): ContextValue { - val obj = JsonObject() - for ((l, r) in pairs) { - obj.addProperty(l, r) - } - // TODO: should this be its own class? - return JsonElementContext(obj) - } - } - - // TODO: allow other serialization formats - fun serialize(): JsonElement - interface Collatable> : ContextValue { - fun combineWith(overrides: T): T - fun actualize(): T - } - - private class LazyCollatable>( - provider: () -> Collatable, - ) : Collatable { - val value by kotlin.lazy(provider) - override fun actualize(): T { - return value.actualize() - } - - override fun combineWith(overrides: T): T { - return value.combineWith(overrides) - } - - override fun serialize(): JsonElement { - return value.serialize() - } - } -} -- cgit