package me.eater.hefbrug.dsl.context.extension_util import me.eater.hefbrug.dsl.context.ContextInterface import me.eater.hefbrug.dsl.scope.ScopeInterface import java.util.* class RuntimeRegister { private val scopeMap = mutableMapOf() @Suppress("UNCHECKED_CAST") fun getScope(context: ContextInterface): T = scopeMap[context]!! as T fun registerScope(context: ContextInterface, scope: ScopeInterface) { scopeMap[context] = scope } companion object { private val runtimeRegisterMap = mutableMapOf() operator fun get(runtimeUUID: UUID) = runtimeRegisterMap.getOrPut(runtimeUUID, { RuntimeRegister() }) fun remove(runtimeUUID: UUID) { runtimeRegisterMap.remove(runtimeUUID) } } }