ListMultimap#asMap

18 views
Skip to first unread message

Nick Partridge

unread,
Apr 6, 2008, 8:58:08 PM4/6/08
to Google Collections Library - users list
Hey,

Is it possible that asMap() for a ListMultimap could be changed to
return a Map<K, List<V>>, rather than the Map<K, Collection<V>> that
it returns now? It seems a bit inconsistent with the behaviour of get
(which does return a List).

Thanks,
Nick Partridge

kevin bourrillion

unread,
Apr 8, 2008, 5:29:34 PM4/8/08
to Nick Partridge, Google Collections Library - users list
In order for this override to be possible, Multimap.asMap() must be defined to return Map<K, ? extends Collection<V>>, and ListMultimap.asMap() Map<K, ? extends List<V>>.

But wildcards in return types of methods == user sadness.  You have to push that "? extends" all throughout your own code.

Jared made this change once, and thankfully saw the damage it did to user code and backed out.
--
Kevin Bourrillion @ Google
internal: go/javalibraries
google-collections.googlecode.com
google-guice.googlecode.com

Nick Partridge

unread,
Apr 9, 2008, 1:24:03 AM4/9/08
to kevin bourrillion, Google Collections Library - users list
Ah right, I hadn't considered that. Thanks :)
-Nick
Reply all
Reply to author
Forward
0 new messages