Description
Hello.
The standard JDK Map<K, V>
interfaces contain methods such as containsKey
that take an Object
instead of a K
, throwing away type-safety. I believe this is now considered to be a serious historical mistake and dangerous to the point that some IDEs have added specific checks to warn users when they might be using keys that aren't subtypes of K
. I'm wondering if there are any plans to add additional type-safe replacement methods to the MutableMap
and ImmutableMap
interfaces specified in the GS API? Something along the lines of:
Optional<V> retrieve(K k)
boolean hasKey(K k);
... or:
@Nullable V retrieve(K k)
... if a dependency on Java 8 isn't allowed.
As far as I can tell, the implementations would be trivial and non-intrusive, and would obviously just be defined in terms of the existing unsafe methods.