Reputation: 71
I need to create an object of type MultiValueMap
package org.springframework.util;
public interface MultiValueMap<K, V> extends Map<K, List<V>> {
and use it as a HashMap. What object shall I use? I tried HashMap but it didn't work.
Upvotes: 5
Views: 13304
Reputation: 308
if you need a blind implementation you can use LinkedMultiValueMap<String, String>
Upvotes: 3
Reputation: 2305
You can also use the convenient util function to adapt one from a map.
org.springframework.util.CollectionUtils#toMultiValueMap
Upvotes: 4
Reputation: 1618
According to these docs: https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/MultiValueMap.html, there are several classes that implement this interface.
You don't specify the context of what you need the class for so we can't tell you which one you should use. The most general one appears to be org.springframework.util.LinkedMultiValueMap
(https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/LinkedMultiValueMap.html).
Upvotes: 8