Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImmutableSetMultimap<K, V> to Map<K, ImmutableSet<V>> #3750

Open
oliviercailloux opened this issue Dec 23, 2019 · 1 comment
Open

ImmutableSetMultimap<K, V> to Map<K, ImmutableSet<V>> #3750

oliviercailloux opened this issue Dec 23, 2019 · 1 comment
Labels
P3 package=collect type=enhancement Make an existing feature better

Comments

@oliviercailloux
Copy link

There’s Multimaps.asMap to transform a SetMultimap<K, V> to a Map<K, Set<V>>, but there’s no Multimaps.asMap to transform an ImmutableSetMultimap<K, V> to a Map<K, ImmutableSet<V>>, it seems.

Have you considered adding this method? Is it already available somehow?

Currently I copy the content into a new ImmutableSetMultimap, which seems unnecessary: Multimaps.asMap(myImmutableSetMultimap).entrySet().stream().collect(ImmutableMap.toImmutableMap((e) -> e.getKey(), (e) -> ImmutableSet.copyOf(e.getValue())))

@cpovirk
Copy link
Member

cpovirk commented Dec 23, 2019

We talked about this at least once. The main complication I recall is that it's not source-compatible: A call to asMap(immutableSetMultimap) would change return types as you've indicated, and the new type might not work where the old does. It's still a possibility -- maybe under another method name? -- we're just not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 package=collect type=enhancement Make an existing feature better
Projects
None yet
Development

No branches or pull requests

2 participants