commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: svn commit: r1449876 - in /commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils: ConstructorUtils.java MethodUtils.java
Date Mon, 25 Feb 2013 21:36:06 GMT
2013/2/25 Simone Tripodi <simonetripodi@apache.org>

> sounds reasonable
>
> > Still don't like it to have the exact same logic in two places. Any idea
> > where to put this? I thought of creating a package private
> "ParameterUtils"
> > or "ObjectUtils" or something like that...
>
> how did we manage that in BU2?
>

We did not have the need for that kind of handling in BU2 because we used
varargs.


> -Simo
>
> http://people.apache.org/~simonetripodi/
> http://simonetripodi.livejournal.com/
> http://twitter.com/simonetripodi
> http://www.99soft.org/
>
>
> On Mon, Feb 25, 2013 at 9:41 PM, Benedikt Ritter <britter@apache.org>
> wrote:
> > 2013/2/25 <britter@apache.org>
> >
> >> Author: britter
> >> Date: Mon Feb 25 20:37:28 2013
> >> New Revision: 1449876
> >>
> >> URL: http://svn.apache.org/r1449876
> >> Log:
> >> Invert conditional logic as discussed on the ML (
> >> http://markmail.org/message/psfzd3l7yaxx6n5v)
> >>
> >> Modified:
> >>
> >>
> commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java
> >>
> >>
> commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/MethodUtils.java
> >>
> >> Modified:
> >>
> commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java
> >> URL:
> >>
> http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java?rev=1449876&r1=1449875&r2=1449876&view=diff
> >>
> >>
> ==============================================================================
> >> ---
> >>
> commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java
> >> (original)
> >> +++
> >>
> commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ConstructorUtils.java
> >> Mon Feb 25 20:37:28 2013
> >> @@ -81,10 +81,7 @@ public class ConstructorUtils {
> >>              InvocationTargetException,
> >>              InstantiationException {
> >>
> >> -        Object[] args = { arg };
> >> -        if (arg == null) {
> >> -            args = null;
> >> -        }
> >> +        Object[] args = toArray(arg);
> >>          return invokeConstructor(klass, args);
> >>      }
> >>
> >> @@ -193,10 +190,7 @@ public class ConstructorUtils {
> >>              InvocationTargetException,
> >>              InstantiationException {
> >>
> >> -        Object[] args = { arg };
> >> -        if (arg == null) {
> >> -            args = null;
> >> -        }
> >> +        Object[] args = toArray(arg);
> >>          return invokeExactConstructor(klass, args);
> >>      }
> >>
> >> @@ -344,6 +338,14 @@ public class ConstructorUtils {
> >>          return null;
> >>      }
> >>
> >> +    private static Object[] toArray(Object arg) {
> >> +        Object[] args = null;
> >> +        if (arg != null) {
> >> +            args = new Object[] { arg };
> >> +        }
> >> +        return args;
> >> +    }
> >> +
> >>      // -------------------------------------------------------- Private
> >> Methods
> >>      /**
> >>       * <p>Find an accessible constructor with compatible parameters.
> >>
> >> Modified:
> >>
> commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/MethodUtils.java
> >> URL:
> >>
> http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/MethodUtils.java?rev=1449876&r1=1449875&r2=1449876&view=diff
> >>
> >>
> ==============================================================================
> >> ---
> >>
> commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/MethodUtils.java
> >> (original)
> >> +++
> >>
> commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/MethodUtils.java
> >> Mon Feb 25 20:37:28 2013
> >> @@ -671,9 +671,9 @@ public class MethodUtils {
> >>
> >>
> >>      private static Object[] toArray(Object arg) {
> >> -        Object[] args = {arg};
> >> -        if (arg == null) {
> >> -            args = null;
> >> +        Object[] args = null;
> >> +        if (arg != null) {
> >> +            args = new Object[] { arg };
> >>          }
> >>          return args;
> >>      }
> >>
> >>
> >>
> > Still don't like it to have the exact same logic in two places. Any idea
> > where to put this? I thought of creating a package private
> "ParameterUtils"
> > or "ObjectUtils" or something like that...
> >
> > Benedikt
> >
> >
> > --
> > http://people.apache.org/~britter/
> > http://www.systemoutprintln.de/
> > http://twitter.com/BenediktRitter
> > http://github.com/britter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

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