Author: djones
Date: Sat May 10 07:22:22 2014
New Revision: 1593679

URL: http://svn.apache.org/r1593679
Log:
Using Validate where possible in math package.

Modified:
    
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
    
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java

Modified: 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
URL: 
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java?rev=1593679&r1=1593678&r2=1593679&view=diff
==============================================================================
--- 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
 (original)
+++ 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java
 Sat May 10 07:22:22 2014
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.lang3.math;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * <p>Provides IEEE-754r variants of NumberUtils methods. </p>
  *
@@ -39,9 +41,9 @@ public class IEEE754rUtils {
         // Validates input
         if (array == null) {
             throw new IllegalArgumentException("The Array must not be null");
-        } else if (array.length == 0) {
-            throw new IllegalArgumentException("Array cannot be empty.");
-        }
+        } 
+        Validate.isTrue(array.length != 0, "Array cannot be empty.");
+        
     
         // Finds and returns min
         double min = array[0];
@@ -65,10 +67,9 @@ public class IEEE754rUtils {
         // Validates input
         if (array == null) {
             throw new IllegalArgumentException("The Array must not be null");
-        } else if (array.length == 0) {
-            throw new IllegalArgumentException("Array cannot be empty.");
-        }
-    
+        } 
+        Validate.isTrue(array.length != 0, "Array cannot be empty.");
+        
         // Finds and returns min
         float min = array[0];
         for (int i = 1; i < array.length; i++) {
@@ -159,10 +160,9 @@ public class IEEE754rUtils {
         // Validates input
         if (array== null) {
             throw new IllegalArgumentException("The Array must not be null");
-        } else if (array.length == 0) {
-            throw new IllegalArgumentException("Array cannot be empty.");
-        }
-    
+        }         
+        Validate.isTrue(array.length != 0, "Array cannot be empty.");
+        
         // Finds and returns max
         double max = array[0];
         for (int j = 1; j < array.length; j++) {
@@ -185,10 +185,9 @@ public class IEEE754rUtils {
         // Validates input
         if (array == null) {
             throw new IllegalArgumentException("The Array must not be null");
-        } else if (array.length == 0) {
-            throw new IllegalArgumentException("Array cannot be empty.");
-        }
-
+        } 
+        Validate.isTrue(array.length != 0, "Array cannot be empty.");
+        
         // Finds and returns max
         float max = array[0];
         for (int j = 1; j < array.length; j++) {

Modified: 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
URL: 
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java?rev=1593679&r1=1593678&r2=1593679&view=diff
==============================================================================
--- 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
 (original)
+++ 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
 Sat May 10 07:22:22 2014
@@ -21,6 +21,7 @@ import java.math.BigDecimal;
 import java.math.BigInteger;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.Validate;
 
 /**
  * <p>Provides extra functionality for Java Number classes.</p>
@@ -1092,9 +1093,8 @@ public class NumberUtils {
     private static void validateArray(final Object array) {
         if (array == null) {
             throw new IllegalArgumentException("The Array must not be null");
-        } else if (Array.getLength(array) == 0) {
-            throw new IllegalArgumentException("Array cannot be empty.");
-        }
+        }        
+        Validate.isTrue(Array.getLength(array) != 0, "Array cannot be 
empty.");        
     }
      
     // 3 param min


Reply via email to