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

Additional constructor methods for ImmutableMap/Multimaps #861

Closed
gissuebot opened this issue Oct 31, 2014 · 1 comment
Closed

Additional constructor methods for ImmutableMap/Multimaps #861

gissuebot opened this issue Oct 31, 2014 · 1 comment

Comments

@gissuebot
Copy link

Original issue created by bordoley on 2012-01-11 at 05:09 AM


Would it be possible to add the following static methods (or similar) to ImmutableMap/Multimap etc:

ImmutableMultimap.of(Iterable<Map.Entry<K,V>>)
ImmutableMultimap.Builder.putAll(Iterable<Map.Entry<K,V>>)

Use case would be where you want to transform a Multimap<K1,V> to Multimap<K2,V>

I'm imagining something like:

    Multimap<Object, String> in = ....;
    ImmutableMultimap<String, String> out = 
            ImmutableMultimap.of(
                    Iterables.transform(in.entries(), 
                            new Function<Map.Entry<Object,String>, Map.Entry<String,String>>() {
                                @Override
                                public Map.Entry<String, String> apply(Map.Entry<Object, String> input) {
                                    return new AbstractMap.SimpleEntry(input.getKey().toString(), input.getValue());
                                }}));
@gissuebot
Copy link
Author

Original comment posted by wasserman.louis on 2012-01-11 at 05:13 PM


(No comment entered for this change.)


Status: Duplicate
Merged Into: #320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant