logging-commits mailing list archives

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

URL: http://svn.apache.org/r1586401
Log:
Extract 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=1586401&r1=1586400&r2=1586401&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:41:23 2014
@@ -808,13 +808,7 @@ public abstract class AbstractConfigurat
                             );
                             break;
                         }
-                        final Object[] array = (Object[]) Array.newInstance(parmClass, list.size());
-                        int i = 0;
-                        for (final Object obj : list) {
-                            array[i] = obj;
-                            ++i;
-                        }
-                        parms[index] = array;
+                        parms[index] = collectionToArray(list, parmClass);
                     } else {
                         final Class<?> parmClass = parmClasses[index];
                         boolean present = false;
@@ -894,6 +888,16 @@ public abstract class AbstractConfigurat
         return null;
     }
 
+    private static Object[] collectionToArray(final Collection<?> collection, final
Class<?> type) {
+        final Object[] array = (Object[]) Array.newInstance(type, collection.size());
+        int i = 0;
+        for (final Object obj : collection) {
+            array[i] = obj;
+            ++i;
+        }
+        return array;
+    }
+
     private String[] extractPluginAliases(final Annotation... parmTypes) {
         String[] aliases = null;
         for (final Annotation a : parmTypes) {



Mime
View raw message