commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r915110 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
Date Mon, 22 Feb 2010 23:22:19 GMT
Author: niallp
Date: Mon Feb 22 23:22:18 2010
New Revision: 915110

URL: http://svn.apache.org/viewvc?rev=915110&view=rev
Log:
Minor code simplification

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java?rev=915110&r1=915109&r2=915110&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java Mon Feb
22 23:22:18 2010
@@ -457,9 +457,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static Object[] nullToEmpty(Object[] array) {
-        if (array == null) {
-            return EMPTY_OBJECT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_OBJECT_ARRAY;
         }
         return array;
@@ -478,9 +476,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static String[] nullToEmpty(String[] array) {
-        if (array == null) {
-            return EMPTY_STRING_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_STRING_ARRAY;
         }
         return array;
@@ -499,10 +495,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static long[] nullToEmpty(long[] array) {
-        if (array == null) {
-            return EMPTY_LONG_ARRAY;
-        }
-        if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_LONG_ARRAY;
         }
         return array;
@@ -521,9 +514,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static int[] nullToEmpty(int[] array) {
-        if (array == null) {
-            return EMPTY_INT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_INT_ARRAY;
         }
         return array;
@@ -542,9 +533,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static short[] nullToEmpty(short[] array) {
-        if (array == null) {
-            return EMPTY_SHORT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_SHORT_ARRAY;
         }
         return array;
@@ -563,9 +552,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static char[] nullToEmpty(char[] array) {
-        if (array == null) {
-            return EMPTY_CHAR_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_CHAR_ARRAY;
         }
         return array;
@@ -584,9 +571,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static byte[] nullToEmpty(byte[] array) {
-        if (array == null) {
-            return EMPTY_BYTE_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_BYTE_ARRAY;
         }
         return array;
@@ -605,9 +590,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static double[] nullToEmpty(double[] array) {
-        if (array == null) {
-            return EMPTY_DOUBLE_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_DOUBLE_ARRAY;
         }
         return array;
@@ -626,9 +609,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static float[] nullToEmpty(float[] array) {
-        if (array == null) {
-            return EMPTY_FLOAT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_FLOAT_ARRAY;
         }
         return array;
@@ -647,9 +628,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static boolean[] nullToEmpty(boolean[] array) {
-        if (array == null) {
-            return EMPTY_BOOLEAN_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_BOOLEAN_ARRAY;
         }
         return array;
@@ -668,9 +647,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static Long[] nullToEmpty(Long[] array) {
-        if (array == null) {
-            return EMPTY_LONG_OBJECT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_LONG_OBJECT_ARRAY;
         }
         return array;
@@ -689,9 +666,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static Integer[] nullToEmpty(Integer[] array) {
-        if (array == null) {
-            return EMPTY_INTEGER_OBJECT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_INTEGER_OBJECT_ARRAY;
         }
         return array;
@@ -710,9 +685,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static Short[] nullToEmpty(Short[] array) {
-        if (array == null) {
-            return EMPTY_SHORT_OBJECT_ARRAY;
-        }else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_SHORT_OBJECT_ARRAY;
         }
         return array;
@@ -731,9 +704,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static Character[] nullToEmpty(Character[] array) {
-        if (array == null) {
-            return EMPTY_CHARACTER_OBJECT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_CHARACTER_OBJECT_ARRAY;
         }
         return array;
@@ -752,9 +723,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static Byte[] nullToEmpty(Byte[] array) {
-        if (array == null) {
-            return EMPTY_BYTE_OBJECT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_BYTE_OBJECT_ARRAY;
         }
         return array;
@@ -773,9 +742,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static Double[] nullToEmpty(Double[] array) {
-        if (array == null) {
-            return EMPTY_DOUBLE_OBJECT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_DOUBLE_OBJECT_ARRAY;
         }
         return array;
@@ -794,9 +761,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static Float[] nullToEmpty(Float[] array) {
-        if (array == null) {
-            return EMPTY_FLOAT_OBJECT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_FLOAT_OBJECT_ARRAY;
         }
         return array;
@@ -815,9 +780,7 @@
      * @return the same array, <code>public static</code> empty array if <code>null</code>
or empty input
      */
     public static Boolean[] nullToEmpty(Boolean[] array) {
-        if (array == null) {
-            return EMPTY_BOOLEAN_OBJECT_ARRAY;
-        } else if (array.length == 0) {
+        if (array == null || array.length == 0) {
             return EMPTY_BOOLEAN_OBJECT_ARRAY;
         }
         return array;



Mime
View raw message