class DefaultWithMap<M, O>(private val entries: MutableMap<M, O> = mutableMapOf(), private val default: O) {
operator fun getValue(input: M, property: KProperty<*>): O = entries[input] ?: default
operator fun setValue(input: M, property: KProperty<*>, value: O) {
if (value == null) entries.remove(input) else entries[input] = value
}
}