You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by pa...@apache.org on 2018/02/11 10:49:52 UTC

[lang] NumberUtils#isCreatable: remove java 6 only code, as commons-lang requires at java 7+ now

Repository: commons-lang
Updated Branches:
  refs/heads/master f50ec5e60 -> c3b1fefba


NumberUtils#isCreatable: remove java 6 only code, as commons-lang requires at java 7+ now


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/c3b1fefb
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/c3b1fefb
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/c3b1fefb

Branch: refs/heads/master
Commit: c3b1fefbad0c67c8556ba6b4573f135197f87598
Parents: f50ec5e
Author: pascalschumacher <pa...@gmx.net>
Authored: Sun Feb 11 11:49:44 2018 +0100
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sun Feb 11 11:49:44 2018 +0100

----------------------------------------------------------------------
 .../apache/commons/lang3/math/NumberUtils.java   |  7 +------
 .../commons/lang3/math/NumberUtilsTest.java      | 19 ++-----------------
 2 files changed, 3 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c3b1fefb/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
index 1175f5d..5942db7 100644
--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
@@ -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;
             }

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c3b1fefb/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
index 31ca174..20d87fe 100644
--- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
@@ -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);
     }