This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-configuration.git
commit 7fbac5bb4eaf19c036aeea0e9b69ce80f3fcd838 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jul 16 14:26:19 2022 -0400 Use forEach() --- .../java/org/apache/commons/configuration2/XMLListReference.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/commons/configuration2/XMLListReference.java b/src/main/java/org/apache/commons/configuration2/XMLListReference.java index 7ef4d4ac..55730aa4 100644 --- a/src/main/java/org/apache/commons/configuration2/XMLListReference.java +++ b/src/main/java/org/apache/commons/configuration2/XMLListReference.java @@ -16,9 +16,9 @@ */ package org.apache.commons.configuration2; -import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.apache.commons.configuration2.convert.ListDelimiterHandler; import org.apache.commons.configuration2.ex.ConfigurationRuntimeException; @@ -140,15 +140,12 @@ final class XMLListReference { // cannot be null if the current node is a list node final ImmutableNode parent = nodeHandler.getParent(node); final List<ImmutableNode> items = nodeHandler.getChildren(parent, node.getNodeName()); - final List<Object> values = new ArrayList<>(items.size()); - for (final ImmutableNode n : items) { - values.add(n.getValue()); - } + final List<Object> values = items.stream().map(ImmutableNode::getValue).collect(Collectors.toList()); try { return String.valueOf(delimiterHandler.escapeList(values, ListDelimiterHandler.NOOP_TRANSFORMER)); } catch (final UnsupportedOperationException e) { throw new ConfigurationRuntimeException("List handling not supported by " + "the current ListDelimiterHandler! Make sure that the same delimiter " - + "handler is used for loading and saving the configuration.", e); + + "handler is used for loading and saving the configuration.", e); } }