Reputation: 825
Recently I started using Apache Commons MultiKeyMap
for some of my projects and in there I can have multiple values for a value.
MultiKeyMap typePanelUnoMap = new MultiKeyMap();
I want to know whether we can preserve insertion order when using MultiKeyMap
. I know that java.util.LinkedHashMap
can preserve the insertion order.
Map hshmap = new LinkedHashMap()
Can I have the same functionality with MultiKeyMap
?
Thanks,
Keth
Upvotes: 0
Views: 1409
Reputation: 1
Since Apache Commons Collections 4, method multiKeyMap
is being used instead of method decorate
.
So it should be:
MultiKeyMap<String, Object> multiKeyMap= MultiKeyMap.multiKeyMap(new LinkedMap<>());
Upvotes: 0
Reputation: 11875
from the javadocs
This map is implemented as a decorator of a AbstractHashedMap
which enables extra behaviour to be added easily.
MultiKeyMap.decorate(new LinkedMap())
creates an ordered map.
Upvotes: 2