Re: [lang] ObjectUtils enhancement - consumer with non-null value

2020-12-28 Thread Bindul Bhowmik
Gary, LANG-1634 [1] and PR 684 [2] opened for review. Rob - yes exactly. I have found myself writing that utility method multiple times, and almost all of those projects had commons-lang as a dependency, so figured this would be a good place to have this reusable piece of code. Bindul [1] https

Re: [lang] ObjectUtils enhancement - consumer with non-null value

2020-12-28 Thread Rob Spoor
applyIfNonNull looks to be a version of Optional without the Optional object. The following is the same as suggested but with an additional Optional object: Optional.ofNullable(valueX).ifPresent(bean::setValue); Optional.ofNullable(valueX).ifPresent(v -> someObject.compute(v, "bar"));

Re: [lang] ObjectUtils enhancement - consumer with non-null value

2020-12-28 Thread Gary Gregory
Hi Bindul, Let's see what this would look like with a PR :-) Gary On Mon, Dec 28, 2020, 01:23 Bindul Bhowmik wrote: > Hi, > > I would like to propose an enhancement to the ObjectUtils class in lang: > > Background: I have seen multiple places in code where we have to check > if a value is null

[lang] ObjectUtils enhancement - consumer with non-null value

2020-12-27 Thread Bindul Bhowmik
Hi, I would like to propose an enhancement to the ObjectUtils class in lang: Background: I have seen multiple places in code where we have to check if a value is null before using it in a setter or other method, like: if (valueX != null) { bean.setValue(valueX); someObject.com

Re: Lang: ObjectUtils

2013-07-08 Thread Matt Benson
WRT #firstNonNull, I don't know why I couldn't find it before. I do now, and I agree it would seem to fit better in ArrayUtils. Matt On Mon, Jul 8, 2013 at 10:04 AM, Jörg Schaible wrote: > Hi Matt, > > Matt Benson wrote: > > > On Mon, Jul 8, 2013 at 8:22 AM, Jörg Schaible > > wrote: > > > >> H

Re: Lang: ObjectUtils

2013-07-08 Thread Jörg Schaible
Hi Matt, Matt Benson wrote: > On Mon, Jul 8, 2013 at 8:22 AM, Jörg Schaible > wrote: > >> Hi Hen, >> >> Henri Yandell wrote: >> >> > I don't see any value having the first two methods - replacing the '==' >> > sign is a bit too far in the 'provide simple methods' direction I think >> :) >> > >>

Re: Lang: ObjectUtils

2013-07-08 Thread Matt Benson
On Mon, Jul 8, 2013 at 8:22 AM, Jörg Schaible wrote: > Hi Hen, > > Henri Yandell wrote: > > > I don't see any value having the first two methods - replacing the '==' > > sign is a bit too far in the 'provide simple methods' direction I think > :) > > > > I think the third method is already in Lang

Re: Lang: ObjectUtils

2013-07-08 Thread Jörg Schaible
Hi Hen, Henri Yandell wrote: > I don't see any value having the first two methods - replacing the '==' > sign is a bit too far in the 'provide simple methods' direction I think :) > > I think the third method is already in Lang as: > > ArrayUtils.contains(array, null); Well, no, this is n

Re: Lang: ObjectUtils

2013-07-06 Thread Henri Yandell
I don't see any value having the first two methods - replacing the '==' sign is a bit too far in the 'provide simple methods' direction I think :) I think the third method is already in Lang as: ArrayUtils.contains(array, null); Having a containsNull is semantically nice, but I'm not sure it

Re: Lang: ObjectUtils

2013-07-05 Thread Duncan Jones
On 4 July 2013 19:43, 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 ==

Re: Lang: ObjectUtils

2013-07-05 Thread Jörg Schaible
Benedikt Ritter wrote: > You could do this with with CollectionsUtils from [Collections]. > But I think we all agree that implementing a Predicate inline is a lot > more verbose than the proposed method. +1 We have traditionally such convenience methods in lang. When I look at the current argum

Re: Lang: ObjectUtils

2013-07-05 Thread Anshul Zunke
I second Ted. Do we really need this function at all? Just for the sake of adding a piece of code should not run the purpose of adding an API function. On Fri, Jul 5, 2013 at 1:24 AM, Benedikt Ritter wrote: > You could do this with with CollectionsUtils from [Collections]. > But I think we all

Re: Lang: ObjectUtils

2013-07-04 Thread Benedikt Ritter
You could do this with with CollectionsUtils from [Collections]. But I think we all agree that implementing a Predicate inline is a lot more verbose than the proposed method. 2013/7/4 Ted Dunning > A bigger question is why this is needed at all. > > Why not just use composition? In guava, one

Re: Lang: ObjectUtils

2013-07-04 Thread Ted Dunning
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() { @Override public boolean apply(Double input) { return input != null; }

Re: Lang: ObjectUtils

2013-07-04 Thread Dave Brosius
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 cla

Lang: ObjectUtils

2013-07-04 Thread Rafael Santini
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)