You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/07/16 18:41:46 UTC

[commons-configuration] branch master updated (5ea388dd -> b3797292)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-configuration.git


    from 5ea388dd Use forEach()
     new 58c89a9c Use forEach()
     new 6f5fdad7 Use forEach()
     new 7fbac5bb Use forEach()
     new e41a1da5 Better internal exception handling
     new b3797292 Use forEach()

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../configuration2/PropertiesConfigurationLayout.java    |  5 +----
 .../apache/commons/configuration2/XMLConfiguration.java  | 16 +++++++---------
 .../apache/commons/configuration2/XMLListReference.java  |  9 +++------
 .../combined/BaseConfigurationBuilderProvider.java       |  9 +++------
 4 files changed, 14 insertions(+), 25 deletions(-)


[commons-configuration] 04/05: Better internal exception handling

Posted by gg...@apache.org.
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 e41a1da53942f7517f19ebc3bd3662617ee38288
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jul 16 14:28:17 2022 -0400

    Better internal exception handling
---
 .../builder/combined/BaseConfigurationBuilderProvider.java           | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/configuration2/builder/combined/BaseConfigurationBuilderProvider.java b/src/main/java/org/apache/commons/configuration2/builder/combined/BaseConfigurationBuilderProvider.java
index ae3618ef..a2527507 100644
--- a/src/main/java/org/apache/commons/configuration2/builder/combined/BaseConfigurationBuilderProvider.java
+++ b/src/main/java/org/apache/commons/configuration2/builder/combined/BaseConfigurationBuilderProvider.java
@@ -290,9 +290,8 @@ public class BaseConfigurationBuilderProvider implements ConfigurationBuilderPro
      * @return the newly created instance
      * @throws Exception if an error occurs
      */
-    private static BuilderParameters createParameterObject(final String paramcls) throws Exception {
-        final Class<?> cls = ConfigurationUtils.loadClass(paramcls);
-        return (BuilderParameters) cls.newInstance();
+    private static BuilderParameters createParameterObject(final String paramcls) throws ReflectiveOperationException {
+        return (BuilderParameters) ConfigurationUtils.loadClass(paramcls).newInstance();
     }
 
     /**


[commons-configuration] 05/05: Use forEach()

Posted by gg...@apache.org.
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 b37972927adbb9a44b57306acc8429aa5315a4f0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jul 16 14:41:41 2022 -0400

    Use forEach()
---
 .../builder/combined/BaseConfigurationBuilderProvider.java            | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/configuration2/builder/combined/BaseConfigurationBuilderProvider.java b/src/main/java/org/apache/commons/configuration2/builder/combined/BaseConfigurationBuilderProvider.java
index a2527507..3fe96cd0 100644
--- a/src/main/java/org/apache/commons/configuration2/builder/combined/BaseConfigurationBuilderProvider.java
+++ b/src/main/java/org/apache/commons/configuration2/builder/combined/BaseConfigurationBuilderProvider.java
@@ -206,9 +206,7 @@ public class BaseConfigurationBuilderProvider implements ConfigurationBuilderPro
      * @param params the collection with (uninitialized) parameter objects
      */
     protected void inheritParentBuilderProperties(final ConfigurationDeclaration decl, final Collection<BuilderParameters> params) {
-        for (final BuilderParameters p : params) {
-            decl.getConfigurationBuilder().initChildBuilderParameters(p);
-        }
+        params.forEach(p -> decl.getConfigurationBuilder().initChildBuilderParameters(p));
     }
 
     /**


[commons-configuration] 03/05: Use forEach()

Posted by gg...@apache.org.
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 <ga...@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);
         }
     }
 


[commons-configuration] 02/05: Use forEach()

Posted by gg...@apache.org.
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 6f5fdad793c5eb740376034cc658b30d7e1ec615
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jul 16 14:26:14 2022 -0400

    Use forEach()
---
 .../apache/commons/configuration2/XMLConfiguration.java  | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/commons/configuration2/XMLConfiguration.java b/src/main/java/org/apache/commons/configuration2/XMLConfiguration.java
index 1db1a594..ee4417a8 100644
--- a/src/main/java/org/apache/commons/configuration2/XMLConfiguration.java
+++ b/src/main/java/org/apache/commons/configuration2/XMLConfiguration.java
@@ -943,12 +943,12 @@ public class XMLConfiguration extends BaseHierarchicalConfiguration implements F
          * @param refHandler the {@code ReferenceNodeHandler}
          */
         public void handleRemovedNodes(final ReferenceNodeHandler refHandler) {
-            for (final Object ref : refHandler.removedReferences()) {
+            refHandler.removedReferences().forEach(ref -> {
                 if (ref instanceof Node) {
                     final Node removedElem = (Node) ref;
                     removeReference((Element) elementMapping.get(removedElem));
                 }
-            }
+            });
         }
 
         /**
@@ -1076,11 +1076,11 @@ public class XMLConfiguration extends BaseHierarchicalConfiguration implements F
         private static void updateAttributes(final ImmutableNode node, final Element elem) {
             if (node != null && elem != null) {
                 clearAttributes(elem);
-                for (final Map.Entry<String, Object> e : node.getAttributes().entrySet()) {
-                    if (e.getValue() != null) {
-                        elem.setAttribute(e.getKey(), e.getValue().toString());
+                node.getAttributes().forEach((k, v) -> {
+                    if (v != null) {
+                        elem.setAttribute(k, v.toString());
                     }
-                }
+                });
             }
         }
 
@@ -1127,9 +1127,7 @@ public class XMLConfiguration extends BaseHierarchicalConfiguration implements F
             }
 
             // Remove all but the first Text node
-            for (final Node tn : textNodes) {
-                elem.removeChild(tn);
-            }
+            textNodes.forEach(elem::removeChild);
             return result;
         }
     }


[commons-configuration] 01/05: Use forEach()

Posted by gg...@apache.org.
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 58c89a9cd058493787ed12166b9f0bb63912f270
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jul 16 14:26:10 2022 -0400

    Use forEach()
---
 .../apache/commons/configuration2/PropertiesConfigurationLayout.java | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/configuration2/PropertiesConfigurationLayout.java b/src/main/java/org/apache/commons/configuration2/PropertiesConfigurationLayout.java
index da5288d7..245864de 100644
--- a/src/main/java/org/apache/commons/configuration2/PropertiesConfigurationLayout.java
+++ b/src/main/java/org/apache/commons/configuration2/PropertiesConfigurationLayout.java
@@ -698,10 +698,7 @@ public class PropertiesConfigurationLayout implements EventListener<Configuratio
      * @param c the layout object to copy
      */
     private void copyFrom(final PropertiesConfigurationLayout c) {
-        for (final String key : c.getKeys()) {
-            final PropertyLayoutData data = c.layoutData.get(key);
-            layoutData.put(key, data.clone());
-        }
+        c.getKeys().forEach(key -> layoutData.put(key, c.layoutData.get(key).clone()));
 
         setHeaderComment(c.getHeaderComment());
         setFooterComment(c.getFooterComment());