NumberUtils#isCreatable: remove java 6 only code, as commons-lang requires at java 7+ now
This commit is contained in:
parent
f50ec5e608
commit
c3b1fefbad
|
@ -21,7 +21,6 @@ import java.math.BigDecimal;
|
|||
import java.math.BigInteger;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
/**
|
||||
|
@ -1394,7 +1393,7 @@ public class NumberUtils {
|
|||
*
|
||||
* @param str the <code>String</code> to check
|
||||
* @return <code>true</code> if the string is a correctly formatted number
|
||||
* @since 3.5 the code supports the "+" suffix on numbers except for integers in Java 1.6
|
||||
* @since 3.5
|
||||
*/
|
||||
public static boolean isCreatable(final String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
|
@ -1408,7 +1407,6 @@ public class NumberUtils {
|
|||
boolean foundDigit = false;
|
||||
// deal with any possible sign up front
|
||||
final int start = chars[0] == '-' || chars[0] == '+' ? 1 : 0;
|
||||
final boolean hasLeadingPlusSign = start == 1 && chars[0] == '+';
|
||||
if (sz > start + 1 && chars[start] == '0') { // leading 0
|
||||
if (chars[start + 1] == 'x' || chars[start + 1] == 'X') { // leading 0x/0X
|
||||
int i = start + 2;
|
||||
|
@ -1475,9 +1473,6 @@ public class NumberUtils {
|
|||
}
|
||||
if (i < chars.length) {
|
||||
if (chars[i] >= '0' && chars[i] <= '9') {
|
||||
if (SystemUtils.IS_JAVA_1_6 && hasLeadingPlusSign && !hasDecPoint) {
|
||||
return false;
|
||||
}
|
||||
// no type qualifier, OK
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.lang.reflect.Modifier;
|
|||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -1298,14 +1297,7 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testLANG1252() {
|
||||
//Check idiosyncrasies between java 1.6 and 1.7, 1.8 regarding leading + signs
|
||||
if (SystemUtils.IS_JAVA_1_6) {
|
||||
compareIsCreatableWithCreateNumber("+2", false);
|
||||
} else {
|
||||
compareIsCreatableWithCreateNumber("+2", true);
|
||||
}
|
||||
|
||||
//The Following should work regardless of 1.6, 1.7, or 1.8
|
||||
compareIsCreatableWithCreateNumber("+2", true);
|
||||
compareIsCreatableWithCreateNumber("+2.0", true);
|
||||
}
|
||||
|
||||
|
@ -1399,14 +1391,7 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testIsNumberLANG1252() {
|
||||
//Check idiosyncrasies between java 1.6 and 1.7,1.8 regarding leading + signs
|
||||
if (SystemUtils.IS_JAVA_1_6) {
|
||||
compareIsNumberWithCreateNumber("+2", false);
|
||||
} else {
|
||||
compareIsNumberWithCreateNumber("+2", true);
|
||||
}
|
||||
|
||||
//The Following should work regardless of 1.6, 1.7, or 1.8
|
||||
compareIsNumberWithCreateNumber("+2", true);
|
||||
compareIsNumberWithCreateNumber("+2.0", true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue