Polishing in data binding tests
See gh-32676
This commit is contained in:
@@ -148,13 +148,19 @@ public class WebExchangeDataBinder extends WebDataBinder {
|
||||
|
||||
protected static void addBindValue(Map<String, Object> params, String key, List<?> values) {
|
||||
if (!CollectionUtils.isEmpty(values)) {
|
||||
values = values.stream()
|
||||
.map(value -> value instanceof FormFieldPart formFieldPart ? formFieldPart.value() : value)
|
||||
.toList();
|
||||
params.put(key, values.size() == 1 ? values.get(0) : values);
|
||||
if (values.size() == 1) {
|
||||
params.put(key, adaptBindValue(values.get(0)));
|
||||
}
|
||||
else {
|
||||
params.put(key, values.stream().map(WebExchangeDataBinder::adaptBindValue).toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Object adaptBindValue(Object value) {
|
||||
return (value instanceof FormFieldPart part ? part.value() : value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolve values from a map.
|
||||
|
||||
Reference in New Issue
Block a user