Hi, Instead of using a predicate, wouldn't it be simpler to just use if (false == Arrays.asList(obj1, obj2, ...).contains(null)) ?
Just my 2 cents, Julien 2013/7/5 Romain Manni-Bucau <rmannibu...@gmail.com>: > Hi > > I'd just provide a IsNullPredicate class (a singleton) and then use > commons-collection to select the subcollection and if size is 0 or original > size (depend what you test) it would be true > > That said with next java version it will be quite useless IMO > Le 4 juil. 2013 22:04, "Rafael Santini" <raf...@santini.eti.br> a écrit : > >> Hi Ted, >> >> I have some codes that needs to test whether a set of objects are all true >> or not. For example: >> >> if (obj1 != null && obj2 != null && obj3 != null && obj4 != null) { >> // Do something... >> } >> >> So, for readability reason, I have replaced for: >> >> if (isNotTrue(obj1, obj2, obj3, obj4) { >> // Do something... >> } >> >> So I would like something like the isNotNull(Object... objects) method in >> Commons Lang instead of maintain this method in my own framework. >> >> Thanks, >> >> Rafael Santini >> >> -----Mensagem Original----- From: Ted Dunning >> Sent: Thursday, July 04, 2013 4:34 PM >> To: Commons Developers List >> Subject: Re: Lang: ObjectUtils >> >> A bigger question is why this is needed at all. >> >> Why not just use composition? In guava, one would do this: >> >> Iterables.all(Arrays.asList(**foo), new Predicate<Double>() { >> @Override >> public boolean apply(Double input) { >> return input != null; >> } >> }); >> >> Surely the same is already possible with commons. >> >> >> >> On Thu, Jul 4, 2013 at 12:23 PM, Dave Brosius <dbros...@mebigfatguy.com>** >> wrote: >> >> This implies that having arrays with some null elements is >>> >>> a) somewhat common >>> 2) a good idea >>> >>> >>> I'd say both are not true. >>> >>> I'm not sure the library should promote that the above is the case. >>> >>> >>> >>> On 07/04/2013 02:43 PM, Rafael Santini wrote: >>> >>> Hi, >>>> >>>> I would like to propose a method in ObjectUtils class that receives an >>>> array of objects and returns true if all objects are not null. I have >>>> implemented the following: >>>> >>>> public static boolean isNull(Object object) { >>>> return object == null; >>>> } >>>> >>>> public static boolean isNotNull(Object object) { >>>> return isNull(object) == false; >>>> } >>>> >>>> public static boolean isNotNull(Object... objects) { >>>> for (Object object : objects) { >>>> if (isNull(object)) { >>>> return false; >>>> } >>>> } >>>> return true; >>>> } >>>> >>>> Can I submit a patch for this feature? >>>> >>>> Thanks, >>>> >>>> Rafael Santini >>>> >>>> >>>> >>>> >>>> ------------------------------****----------------------------** >>>> --**--------- >>>> To unsubscribe, e-mail: >>>> dev-unsubscribe@commons.**apac**he.org<http://apache.org> >>>> <dev-unsubscribe@**commons.apache.org<dev-unsubscr...@commons.apache.org> >>>> > >>>> For additional commands, e-mail: dev-h...@commons.apache.org >>>> >>>> >>>> >>>> >>> ------------------------------****----------------------------** >>> --**--------- >>> To unsubscribe, e-mail: >>> dev-unsubscribe@commons.**apac**he.org<http://apache.org> >>> <dev-unsubscribe@**commons.apache.org<dev-unsubscr...@commons.apache.org> >>> > >>> For additional commands, e-mail: dev-h...@commons.apache.org >>> >>> >>> >> >> ------------------------------**------------------------------**--------- >> To unsubscribe, e-mail: >> dev-unsubscribe@commons.**apache.org<dev-unsubscr...@commons.apache.org> >> For additional commands, e-mail: dev-h...@commons.apache.org >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org