Using Validate where possible in math package.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1593679 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Duncan Jones 2014-05-10 07:22:22 +00:00
parent a2c356d7a6
commit 5a28357bb5
2 changed files with 17 additions and 18 deletions

View File

@ -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++) {

View File

@ -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