Various MultiValueMap improvements
This commit makes several improvements to MultiValueMap: - asSingleValueMap offers a single-value view (as opposed to the existing toSingleValueMap, which offers a copy) - fromSingleValue is a static method that adapts a Map<?,?> to the MultiValueMap interface - fromMultiValue is a static method that adapts a Map<?,List<?>> to the MultiValueMap interface Closes gh-32832
This commit is contained in:
@@ -1774,6 +1774,10 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
return this.headers.toSingleValueMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> asSingleValueMap() {
|
||||
return this.headers.asSingleValueMap();
|
||||
}
|
||||
|
||||
// Map implementation
|
||||
|
||||
|
||||
@@ -122,6 +122,11 @@ class ReadOnlyHttpHeaders extends HttpHeaders {
|
||||
return Collections.unmodifiableMap(this.headers.toSingleValueMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> asSingleValueMap() {
|
||||
return Collections.unmodifiableMap(this.headers.asSingleValueMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> keySet() {
|
||||
return Collections.unmodifiableSet(this.headers.keySet());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -102,7 +102,7 @@ public abstract class AbstractMultipartHttpServletRequest extends HttpServletReq
|
||||
|
||||
@Override
|
||||
public Map<String, MultipartFile> getFileMap() {
|
||||
return getMultipartFiles().toSingleValueMap();
|
||||
return getMultipartFiles().asSingleValueMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user