2013/2/25 Simone Tripodi <simonetrip...@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 <brit...@apache.org> > wrote: > > 2013/2/25 <brit...@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-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > -- http://people.apache.org/~britter/ http://www.systemoutprintln.de/ http://twitter.com/BenediktRitter http://github.com/britter