commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: [lang] LANG-1289" type="fix" dev="ggregory">JavaVersion class depends on Apache Commons Math class NumberUtils.
Date Fri, 18 Nov 2016 21:39:44 GMT
Gary Gregory <garydgregory@gmail.com> schrieb am Fr., 18. Nov. 2016 um
22:35 Uhr:

> Dang! My bad I will revert. I thought we had introduced a dependency on
> Commons Math.
>

Okay, thank you!

Benedikt


>
> Gary
>
> On Fri, Nov 18, 2016 at 1:29 PM, Benedikt Ritter <britter@apache.org>
> wrote:
>
> > Hello Gary,
> >
> > I don't understand this change. The NumberUtils import you removed was
> > from lang itself. Doesn't this change introduce code duplication within
> > Lang?
> >
> > Benedikt
> >
> > <ggregory@apache.org> schrieb am Fr. 18. Nov. 2016 um 21:30:
> >
> >> Repository: commons-lang
> >> Updated Branches:
> >>   refs/heads/master 429c847b2 -> 9dcd87f9c
> >>
> >>
> >> LANG-1289" type="fix" dev="ggregory">JavaVersion class depends on Apache
> >> Commons Math class NumberUtils.
> >>
> >> Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
> >> Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/
> >> 9dcd87f9
> >> Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/9dcd87f9
> >> Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/9dcd87f9
> >>
> >> Branch: refs/heads/master
> >> Commit: 9dcd87f9c46786f3da54af7ac1ba4696840dffa8
> >> Parents: 429c847
> >> Author: Gary Gregory <ggregory@apache.org>
> >> Authored: Fri Nov 18 12:30:22 2016 -0800
> >> Committer: Gary Gregory <ggregory@apache.org>
> >> Committed: Fri Nov 18 12:30:22 2016 -0800
> >>
> >> ----------------------------------------------------------------------
> >>  src/changes/changes.xml                         |  1 +
> >>  .../org/apache/commons/lang3/JavaVersion.java   | 40
> >> ++++++++++++++++++--
> >>  2 files changed, 37 insertions(+), 4 deletions(-)
> >> ----------------------------------------------------------------------
> >>
> >>
> >> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/
> >> 9dcd87f9/src/changes/changes.xml
> >> ----------------------------------------------------------------------
> >> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
> >> index 63a94a3..092d4c5 100644
> >> --- a/src/changes/changes.xml
> >> +++ b/src/changes/changes.xml
> >> @@ -57,6 +57,7 @@ The <action> type attribute can be
> >> add,update,fix,remove.
> >>      <action issue="LANG-1070" type="fix" dev="pschumacher" due-to="Paul
> >> Pogonyshev">ArrayUtils#add confusing example in javadoc</action>
> >>      <action issue="LANG-1271" type="fix" dev="pschumacher"
> >> due-to="Pierre Templier">StringUtils#isAnyEmpty and #isAnyBlank should
> >> return false for an empty array</action>
> >>      <action issue="LANG-1155" type="fix" dev="pschumacher" due-to="Saif
> >> Asif, Thiago Andrade">Add StringUtils#unwrap</action>
> >> +    <action issue="LANG-1289" type="fix" dev="ggregory">JavaVersion
> >> class depends on Apache Commons Math class NumberUtils</action>
> >>      <action issue="LANG-1034" type="add" dev="pschumacher"
> >> due-to="Yathos UG">Add support for recursive comparison to
> EqualsBuilder#
> >> reflectionEquals</action>
> >>      <action issue="LANG-740" type="add" dev="pschumacher" due-to="James
> >> Sawle">Implementation of a Memomizer</action>
> >>      <action issue="LANG-1258" type="add" dev="pschumacher" due-to="IG,
> >> Grzegorz Ro┼╝niecki">Add ArrayUtils#toStringArray method</action>
> >>
> >> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/
> >> 9dcd87f9/src/main/java/org/apache/commons/lang3/JavaVersion.java
> >> ----------------------------------------------------------------------
> >> diff --git a/src/main/java/org/apache/commons/lang3/JavaVersion.java
> >> b/src/main/java/org/apache/commons/lang3/JavaVersion.java
> >> index 8c992f2..964ec4a 100644
> >> --- a/src/main/java/org/apache/commons/lang3/JavaVersion.java
> >> +++ b/src/main/java/org/apache/commons/lang3/JavaVersion.java
> >> @@ -16,8 +16,6 @@
> >>   */
> >>  package org.apache.commons.lang3;
> >>
> >> -import org.apache.commons.lang3.math.NumberUtils;
> >> -
> >>  /**
> >>   * <p>An enum representing all the versions of the Java specification.
> >>   * This is intended to mirror available values from the
> >> @@ -220,11 +218,45 @@ public enum JavaVersion {
> >>          if (value.contains(".")) {
> >>              final String[] toParse = value.split("\\.");
> >>              if (toParse.length >= 2) {
> >> -                return NumberUtils.toFloat(toParse[0] + '.' +
> >> toParse[1], defaultReturnValue);
> >> +                return toFloat(toParse[0] + '.' + toParse[1],
> >> defaultReturnValue);
> >>              }
> >>          } else {
> >> -            return NumberUtils.toFloat(value, defaultReturnValue);
> >> +            return toFloat(value, defaultReturnValue);
> >>          }
> >>          return defaultReturnValue;
> >>      }
> >> +
> >> +    /**
> >> +     * <p>Convert a <code>String</code> to a <code>float</code>,
> >> returning a
> >> +     * default value if the conversion fails.</p>
> >> +     *
> >> +     * <p>If the string <code>str</code> is <code>null</code>,
the
> >> default
> >> +     * value is returned.</p>
> >> +     *
> >> +     * <pre>
> >> +     *   NumberUtils.toFloat(null, 1.1f)   = 1.0f
> >> +     *   NumberUtils.toFloat("", 1.1f)     = 1.1f
> >> +     *   NumberUtils.toFloat("1.5", 0.0f)  = 1.5f
> >> +     * </pre>
> >> +     *
> >> +     * @param str the string to convert, may be <code>null</code>
> >> +     * @param defaultValue the default value
> >> +     * @return the float represented by the string, or defaultValue
> >> +     *  if conversion fails
> >> +     *
> >> +     *  <p>
> >> +     *  Copied from Apache Commons Math.
> >> +     *  </p>
> >> +     */
> >> +    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;
> >> +      }
> >> +    }
> >> +
> >>  }
> >>
> >>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <
> https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8
> >
>
> <http:////
> ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
> JUnit in Action, Second Edition
> <
> https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22
> >
>
> <http:////
> ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
> Spring Batch in Action
> <
> https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action
> >
> <http:////
> ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message