google / guava

Google core libraries for Java
Apache License 2.0
50.2k stars 10.91k forks source link

MultimapSplitter for multi-value keys #1004

Open gissuebot opened 10 years ago

gissuebot commented 10 years ago

Original issue created by SeanPFloyd on 2012-05-16 at 04:34 PM


The use case I have in mind is parsing HTTP query Strings. I am using this e.g. in log file analysis tools like this:

Map<String, String> queryParameters = Splitter.on('&').withKeyValueSeparator('=').split(queryString);

However, HTTP Requests can have multiple values to the same key, so it would be even nicer to have something like this:

Multimap<String, String> queryParameters = Splitter.on('&').someMethodNameHere('=').split(queryString);

(And since there are many different types of multimaps, there should probably also be an overloaded version that takes a Supplier<Multimap<String, String>>)

gissuebot commented 10 years ago

Original comment posted by wasserman.louis on 2012-05-16 at 06:33 PM


We couldn't do this if we wanted to, because it would require common.base to depend on common.collect.


Status: WontFix

gissuebot commented 10 years ago

Original comment posted by SeanPFloyd on 2012-05-18 at 07:22 AM


Is that because of OSGI?

gissuebot commented 10 years ago

Original comment posted by wasserman.louis on 2012-05-18 at 10:54 PM


No, it's Google's internal build system.

dkirrane commented 9 years ago

+1

kevinb9n commented 9 years ago

Regardless, it could produce an iterable of Map.Entrys, which could then be turned into a multimap.

whiskeysierra commented 9 years ago

+1

reevesy commented 9 years ago

+1

andrei-kalasok commented 7 years ago

+1

braza501 commented 5 years ago

+1

cpovirk commented 5 years ago

I believe we recently approved (but haven't implemented) Splitter.splitToStream. Maybe we should add MapSplitter.splitToStream, as well. That type would also be a candidate for returning a BiStream/MapStream/etc. type, should we ever provide or adopt one of those. (But the new stream type couldn't go in common.collect, as noted above.)