Polishing in data binding tests

See gh-32676
This commit is contained in:
rstoyanchev
2024-06-04 09:55:09 +01:00
parent 36b0702c0b
commit 398aae2b9a
4 changed files with 46 additions and 42 deletions

View File

@@ -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.