Apache Commons MultiMap is deprecated, what should I use now?

WhiteWalker picture WhiteWalker · Dec 30, 2018 · Viewed 10.3k times · Source

Apache Commons' MultiMap interface with its MultiValueMap implementation is deprecated since version 4.1. And MultiHashMap seems to go entirely...

What should I use as an alternative?

Answer

user7294900 picture user7294900 · Dec 30, 2018

MultiValuedMap is the replacement and it isn't deprecated:

Defines a map that holds a collection of values against each key.

For example:

 MultiValuedMap<K, String> map = new MultiValuedHashMap<K, String>();
 map.put(key, "A");
 map.put(key, "B");
 map.put(key, "C");
 Collection<String> coll = map.get(key);

It replaced MultiHashMap

Class now available as MultiValueMap in map subpackage. This version is due to be removed in collections v4.0.

and MultiValueMap:

Deprecated. since 4.1, use MultiValuedMap instead

The deprecation related to apache commons collections4 dependency jar

I think the third you meant MultiMap was deprecated