tiny simplifications regarding usage of Iterator

This commit is contained in:
stsypanov
2019-03-13 21:46:53 +02:00
committed by Juergen Hoeller
parent 8f972a5a60
commit 4cc7b9b9fc
2 changed files with 8 additions and 11 deletions

View File

@@ -390,7 +390,7 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
result.append(UriUtils.encodePathSegment(value.toString(), encodingScheme));
endLastMatch = matcher.end();
}
result.append(targetUrl.substring(endLastMatch, targetUrl.length()));
result.append(targetUrl.substring(endLastMatch));
return result;
}
@@ -456,18 +456,17 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
boolean first = (targetUrl.toString().indexOf('?') < 0);
for (Map.Entry<String, Object> entry : queryProperties(model).entrySet()) {
Object rawValue = entry.getValue();
Iterator<Object> valueIter;
Collection<Object> values;
if (rawValue != null && rawValue.getClass().isArray()) {
valueIter = Arrays.asList(ObjectUtils.toObjectArray(rawValue)).iterator();
values = Arrays.asList(ObjectUtils.toObjectArray(rawValue));
}
else if (rawValue instanceof Collection) {
valueIter = ((Collection<Object>) rawValue).iterator();
values = ((Collection<Object>) rawValue);
}
else {
valueIter = Collections.singleton(rawValue).iterator();
values = Collections.singleton(rawValue);
}
while (valueIter.hasNext()) {
Object value = valueIter.next();
for (Object value : values) {
if (first) {
targetUrl.append('?');
first = false;