logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1586418 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
Date Thu, 10 Apr 2014 18:59:43 GMT
Author: mattsicker
Date: Thu Apr 10 18:59:43 2014
New Revision: 1586418

URL: http://svn.apache.org/r1586418
Log:
Extract another method.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java?rev=1586418&r1=1586417&r2=1586418&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
Thu Apr 10 18:59:43 2014
@@ -810,21 +810,13 @@ public abstract class AbstractConfigurat
                         }
                         parms[index] = collectionToArray(list, parmClass);
                     } else {
-                        final Class<?> parmClass = parmClasses[index];
-                        boolean present = false;
-                        for (final Node child : children) {
-                            final PluginType<?> childType = child.getType();
-                            if (name.equals(childType.getElementName()) ||
-                                    parmClass.isAssignableFrom(childType.getPluginClass()))
{
-                                sb.append(child.getName()).append('(').append(child.toString()).append(')');
-                                present = true;
-                                used.add(child);
-                                parms[index] = child.getObject();
-                                break;
-                            }
-                        }
-                        if (!present) {
+                        final Node child = findNamedNode(name, parmClasses[index], children);
+                        if (child == null) {
                             sb.append("null");
+                        } else {
+                            sb.append(child.getName()).append('(').append(child.toString()).append(')');
+                            used.add(child);
+                            parms[index] = child.getObject();
                         }
                     }
                 }
@@ -898,6 +890,17 @@ public abstract class AbstractConfigurat
         return array;
     }
 
+    private static Node findNamedNode(final String name, final Class<?> type, final
Iterable<Node> nodes) {
+        for (final Node child : nodes) {
+            final PluginType<?> childType = child.getType();
+            if (name.equalsIgnoreCase(childType.getElementName()) ||
+                    type.isAssignableFrom(childType.getPluginClass())) {
+                return child;
+            }
+        }
+        return null;
+    }
+
     private static String[] extractPluginAliases(final Annotation... parmTypes) {
         String[] aliases = null;
         for (final Annotation a : parmTypes) {



Mime
View raw message