SPR-2784: Support MultipartFile-array property

This commit is contained in:
Arjen Poutsma
2009-08-28 09:15:19 +00:00
parent ae8c053568
commit 66a799552f
14 changed files with 277 additions and 67 deletions

View File

@@ -64,7 +64,6 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V> {
this.targetMap = new LinkedHashMap<K, List<V>>(otherMap);
}
// MultiValueMap implementation
public void add(K key, V value) {
@@ -87,6 +86,19 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V> {
this.targetMap.put(key, values);
}
public void setAll(Map<K, V> values) {
for (Entry<K, V> entry : values.entrySet()) {
set(entry.getKey(), entry.getValue());
}
}
public Map<K, V> toSingleValueMap() {
LinkedHashMap<K, V> singleValueMap = new LinkedHashMap<K,V>(this.targetMap.size());
for (Entry<K, List<V>> entry : targetMap.entrySet()) {
singleValueMap.put(entry.getKey(), entry.getValue().get(0));
}
return singleValueMap;
}
// Map implementation

View File

@@ -48,4 +48,16 @@ public interface MultiValueMap<K, V> extends Map<K, List<V>> {
*/
void set(K key, V value);
/**
* Set the given values under.
* @param values the values.
*/
void setAll(Map<K, V> values);
/**
* Returns the first values contained in this {@code MultiValueMap}.
* @return a single value representation of this map
*/
Map<K, V> toSingleValueMap();
}