Introduce static MultiValueMap
factory methods
#32832
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Java 9 introduced static factory methods on the collection interaces, to create immutable collections. We should consider doing the same for
MultiValueMap
.There are several open questions to answer:
MultiValueMap.of("foo", "bar", "baz", "qux")
. Does the resulting map have two entries (foo->bar and baz->qux)? Or does it have one entry, with three values (foo->[bar, baz, qux])? Without reading the javadoc, you would not know, which makes the method problematic.MultiValueMap<K, V> MultiValueMap::of(Map<K, V>)
, so that you could doMultiValueMap.of(Map.of("foo", "bar")
.MultiValueMap<K, V> MultiValueMap::of(Map<K, List<V>>)
, which allowsMultiValueMap.of(Map.of("foo", List.of("bar", "baz"))
.of
variants (single and multi value), they would have to be named differently because of type erasure. For instance,MultiValueMap<K, V> MultiValueMap::ofSingle(Map<K, V>)
andMultiValueMap<K, V> MultiValueMap::ofMulti(Map<K, List<V>>)
The text was updated successfully, but these errors were encountered: