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 84b0c49b5ff2a464f4256edf698212575a9c3b77
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Aug 6 13:28:37 2022 -0400

    Better use of streams
---
 .../commons/configuration2/beanutils/XMLBeanDeclaration.java | 11 +++--------
 .../configuration2/builder/BasicBuilderParameters.java       | 12 +++++-------
 .../apache/commons/configuration2/event/BaseEventSource.java |  4 ++--
 3 files changed, 10 insertions(+), 17 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java
 
b/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java
index 70c23087..003fba6c 100644
--- 
a/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java
+++ 
b/src/main/java/org/apache/commons/configuration2/beanutils/XMLBeanDeclaration.java
@@ -23,6 +23,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import org.apache.commons.configuration2.BaseHierarchicalConfiguration;
@@ -292,14 +293,8 @@ public class XMLBeanDeclaration implements BeanDeclaration 
{
      */
     @Override
     public Map<String, Object> getBeanProperties() {
-        final Map<String, Object> props = new HashMap<>();
-        getAttributeNames().forEach(key -> {
-            if (!isReservedAttributeName(key)) {
-                props.put(key, interpolate(getNode().getAttribute(key)));
-            }
-        });
-
-        return props;
+        return getAttributeNames().stream().filter(e -> 
!isReservedAttributeName(e))
+            .collect(Collectors.toMap(Function.identity(), e -> 
interpolate(getNode().getAttribute(e))));
     }
 
     /**
diff --git 
a/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderParameters.java
 
b/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderParameters.java
index 8b6833fe..4d9cfac9 100644
--- 
a/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderParameters.java
+++ 
b/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderParameters.java
@@ -241,10 +241,9 @@ public class BasicBuilderParameters implements Cloneable, 
BuilderParameters, Bas
         if (p == null) {
             throw new IllegalArgumentException("Parameters to merge must not 
be null!");
         }
-
-        p.getParameters().entrySet().forEach(e -> {
-            if (!properties.containsKey(e.getKey()) && 
!e.getKey().startsWith(RESERVED_PARAMETER_PREFIX)) {
-                storeProperty(e.getKey(), e.getValue());
+        p.getParameters().forEach((k, v) -> {
+            if (!properties.containsKey(k) && 
!k.startsWith(RESERVED_PARAMETER_PREFIX)) {
+                storeProperty(k, v);
             }
         });
     }
@@ -422,9 +421,8 @@ public class BasicBuilderParameters implements Cloneable, 
BuilderParameters, Bas
         if (prefixes == null) {
             return null;
         }
-
-        prefixes.entrySet().forEach(e -> {
-            if (!(e.getKey() instanceof String) || !(e.getValue() instanceof 
Lookup)) {
+        prefixes.forEach((k, v) -> {
+            if (!(k instanceof String) || !(v instanceof Lookup)) {
                 throw new IllegalArgumentException("Map with prefix lookups 
contains invalid data: " + prefixes);
             }
         });
diff --git 
a/src/main/java/org/apache/commons/configuration2/event/BaseEventSource.java 
b/src/main/java/org/apache/commons/configuration2/event/BaseEventSource.java
index ffae17c3..e288ff33 100644
--- a/src/main/java/org/apache/commons/configuration2/event/BaseEventSource.java
+++ b/src/main/java/org/apache/commons/configuration2/event/BaseEventSource.java
@@ -82,7 +82,7 @@ public class BaseEventSource implements EventSource {
      */
     public <T extends Event> Collection<EventListener<? super T>> 
getEventListeners(final EventType<T> eventType) {
         final List<EventListener<? super T>> result = new LinkedList<>();
-        eventListeners.getEventListeners(eventType).forEach(l -> 
result.add(l));
+        eventListeners.getEventListeners(eventType).forEach(result::add);
         return Collections.unmodifiableCollection(result);
     }
 
@@ -145,7 +145,7 @@ public class BaseEventSource implements EventSource {
      * @since 1.4
      */
     public void clearErrorListeners() {
-        
eventListeners.getRegistrationsForSuperType(ConfigurationErrorEvent.ANY).forEach(reg
 -> eventListeners.removeEventListener(reg));
+        
eventListeners.getRegistrationsForSuperType(ConfigurationErrorEvent.ANY).forEach(eventListeners::removeEventListener);
     }
 
     /**

Reply via email to