Guava: MultimapSplitter for multi-value keys

Created on 31 Oct 2014  路  10Comments  路  Source: google/guava

_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>>)

P3 package=collect status=research type=addition

Most helpful comment

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

All 10 comments

_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

_Original comment posted by SeanPFloyd on 2012-05-18 at 07:22 AM_


Is that because of OSGI?

_Original comment posted by wasserman.louis on 2012-05-18 at 10:54 PM_


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

+1

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

+1

+1

+1

+1

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.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hanmac picture Hanmac  路  3Comments

cpovirk picture cpovirk  路  5Comments

Bocete picture Bocete  路  3Comments

PhilippWendler picture PhilippWendler  路  4Comments

oliviercailloux picture oliviercailloux  路  4Comments