Add toString for TypeSafeMap implementations

This commit is contained in:
Him188 2021-08-16 19:51:43 +08:00
parent 49c6734722
commit 1ffa9eb957

View File

@ -73,6 +73,10 @@ internal open class TypeSafeMapImpl(
return map.hashCode()
}
override fun toString(): String {
return "TypeSafeMapImpl(map=$map)"
}
override operator fun <T> get(key: TypeKey<T>): T =
map[key.name]?.uncheckedCast() ?: throw NoSuchElementException(key.toString())
@ -94,6 +98,10 @@ internal class MutableTypeSafeMapImpl(
return map.hashCode()
}
override fun toString(): String {
return "MutableTypeSafeMapImpl(map=$map)"
}
override operator fun <T> set(key: TypeKey<T>, value: T) {
map[key.name] = value
}