A. Karnaval
A. Karnaval

Reputation: 71

What implements MultiValueMap?

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

Answers (3)

Lequerica Martin
Lequerica Martin

Reputation: 308

if you need a blind implementation you can use LinkedMultiValueMap<String, String>

Upvotes: 3

L&#233;o Schneider
L&#233;o Schneider

Reputation: 2305

You can also use the convenient util function to adapt one from a map.

org.springframework.util.CollectionUtils#toMultiValueMap

Upvotes: 4

pcarter
pcarter

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

Related Questions