|
22 | 22 | import java.lang.reflect.Array;
|
23 | 23 | import java.lang.reflect.InvocationTargetException;
|
24 | 24 | import java.lang.reflect.Method;
|
25 |
| -import java.util.ArrayList; |
26 | 25 | import java.util.Collection;
|
27 | 26 | import java.util.HashMap;
|
28 | 27 | import java.util.List;
|
@@ -243,9 +242,9 @@ public void copyProperties(final Object dest, final Object orig)
|
243 | 242 | // Map properties are always of type <String, Object>
|
244 | 243 | Map<String, Object> propMap = (Map<String, Object>) orig;
|
245 | 244 | for (final Map.Entry<String, Object> entry : propMap.entrySet()) {
|
246 |
| - final String name = entry.getKey(); |
247 |
| - if (getPropertyUtils().isWriteable(dest, name)) { |
248 |
| - copyProperty(dest, name, entry.getValue()); |
| 245 | + final String k = entry.getKey(); |
| 246 | + if (getPropertyUtils().isWriteable(dest, k)) { |
| 247 | + copyProperty(dest, k, entry.getValue()); |
249 | 248 | }
|
250 | 249 | }
|
251 | 250 | } else /* if (orig is a standard JavaBean) */ {
|
@@ -514,16 +513,7 @@ public String[] getArrayProperty(final Object bean, final String name)
|
514 | 513 | return null;
|
515 | 514 | }
|
516 | 515 | if (value instanceof Collection) {
|
517 |
| - final ArrayList<String> values = new ArrayList<>(); |
518 |
| - for (final Object item : (Collection<?>) value) { |
519 |
| - if (item == null) { |
520 |
| - values.add(null); |
521 |
| - } else { |
522 |
| - // convert to string using convert utils |
523 |
| - values.add(getConvertUtils().convert(item)); |
524 |
| - } |
525 |
| - } |
526 |
| - return values.toArray(new String[values.size()]); |
| 516 | + return ((Collection<?>) value).stream().map(item -> item != null ? getConvertUtils().convert(item) : null).toArray(String[]::new); |
527 | 517 | }
|
528 | 518 | if (!value.getClass().isArray()) {
|
529 | 519 | final String[] results = new String[1];
|
|
0 commit comments