From f55530a2ffd3c481f6554d98e9d73f2e8c62ec8d Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 18 Nov 2016 13:36:09 -0800 Subject: [PATCH] Revert "LANG-1289" type="fix" dev="ggregory">JavaVersion class depends on Apache Commons Math class NumberUtils." This reverts commit 9dcd87f9c46786f3da54af7ac1ba4696840dffa8. --- src/changes/changes.xml | 1 - .../org/apache/commons/lang3/JavaVersion.java | 40 ++----------------- 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 092d4c591..63a94a318 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -57,7 +57,6 @@ The type attribute can be add,update,fix,remove. ArrayUtils#add confusing example in javadoc StringUtils#isAnyEmpty and #isAnyBlank should return false for an empty array Add StringUtils#unwrap - JavaVersion class depends on Apache Commons Math class NumberUtils Add support for recursive comparison to EqualsBuilder#reflectionEquals Implementation of a Memomizer Add ArrayUtils#toStringArray method diff --git a/src/main/java/org/apache/commons/lang3/JavaVersion.java b/src/main/java/org/apache/commons/lang3/JavaVersion.java index 964ec4a9a..8c992f2ae 100644 --- a/src/main/java/org/apache/commons/lang3/JavaVersion.java +++ b/src/main/java/org/apache/commons/lang3/JavaVersion.java @@ -16,6 +16,8 @@ */ package org.apache.commons.lang3; +import org.apache.commons.lang3.math.NumberUtils; + /** *

An enum representing all the versions of the Java specification. * This is intended to mirror available values from the @@ -218,45 +220,11 @@ public enum JavaVersion { if (value.contains(".")) { final String[] toParse = value.split("\\."); if (toParse.length >= 2) { - return toFloat(toParse[0] + '.' + toParse[1], defaultReturnValue); + return NumberUtils.toFloat(toParse[0] + '.' + toParse[1], defaultReturnValue); } } else { - return toFloat(value, defaultReturnValue); + return NumberUtils.toFloat(value, defaultReturnValue); } return defaultReturnValue; } - - /** - *

Convert a String to a float, returning a - * default value if the conversion fails.

- * - *

If the string str is null, the default - * value is returned.

- * - *
-     *   NumberUtils.toFloat(null, 1.1f)   = 1.0f
-     *   NumberUtils.toFloat("", 1.1f)     = 1.1f
-     *   NumberUtils.toFloat("1.5", 0.0f)  = 1.5f
-     * 
- * - * @param str the string to convert, may be null - * @param defaultValue the default value - * @return the float represented by the string, or defaultValue - * if conversion fails - * - *

- * Copied from Apache Commons Math. - *

- */ - private static float toFloat(final String str, final float defaultValue) { - if (str == null) { - return defaultValue; - } - try { - return Float.parseFloat(str); - } catch (final NumberFormatException nfe) { - return defaultValue; - } - } - }