new feature: coalesce operator / method

6 messages Options
Embed this post
Permalink
tmenzel

new feature: coalesce operator / method

Reply Threaded More More options
Print post
Permalink
hi,

after writing an if (x != null) {o = ...} else if (y != null) {o = } ...
cascade, i just thought that we could use a coalesce operator in java as well....


until sun will support this i think this could be hosted somewhere in the commons.lang package:

Operators.coalesce(final Object... object);

this then would return the first non-null objecet from the given list/array.

alternatively this could also go on ObjectUtils.

what do u think?

--
Neu: GMX DSL bis 50.000 kBit/s und 200,- Euro Startguthaben!
http://portal.gmx.net/de/go/dsl02

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Ted Dunning

Re: new feature: coalesce operator / method

Reply Threaded More More options
Print post
Permalink
Write up a JIRA and a patch and go for it!

I would recommend that the name be "firstNonNull" rather than "coalesce".
The verb coalesce implies things coming together rather than selecting one
of many.

On Fri, Oct 30, 2009 at 6:39 AM, thomas menzel <[hidden email]>wrote:

> hi,
>
> after writing an if (x != null) {o = ...} else if (y != null) {o = } ...
> cascade, i just thought that we could use a coalesce operator in java as
> well....
>
>
> until sun will support this i think this could be hosted somewhere in the
> commons.lang package:
>
> Operators.coalesce(final Object... object);
>
> this then would return the first non-null objecet from the given
> list/array.
>
> alternatively this could also go on ObjectUtils.
>
> what do u think?
>
> --
> Neu: GMX DSL bis 50.000 kBit/s und 200,- Euro Startguthaben!
> http://portal.gmx.net/de/go/dsl02
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Ted Dunning, CTO
DeepDyve
tmenzel

RE: new feature: coalesce operator / method

Reply Threaded More More options
Print post
Permalink
Done. See https://issues.apache.org/jira/browse/LANG-550



> -----Original Message-----
> From: Ted Dunning [mailto:[hidden email]]
> Sent: Freitag, 30. Oktober 2009 20:56
> To: Commons Users List
> Subject: Re: new feature: coalesce operator / method
>
> Write up a JIRA and a patch and go for it!
>
> I would recommend that the name be "firstNonNull" rather than
> "coalesce".
> The verb coalesce implies things coming together rather than selecting
> one
> of many.
>
> On Fri, Oct 30, 2009 at 6:39 AM, thomas menzel
> <[hidden email]>wrote:
>
> > hi,
> >
> > after writing an if (x != null) {o = ...} else if (y != null) {o = }
> ...
> > cascade, i just thought that we could use a coalesce operator in java
> as
> > well....
> >
> >
> > until sun will support this i think this could be hosted somewhere in
> the
> > commons.lang package:
> >
> > Operators.coalesce(final Object... object);
> >
> > this then would return the first non-null objecet from the given
> > list/array.
> >
> > alternatively this could also go on ObjectUtils.
> >
> > what do u think?
> >
> > --
> > Neu: GMX DSL bis 50.000 kBit/s und 200,- Euro Startguthaben!
> > http://portal.gmx.net/de/go/dsl02
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
> --
> Ted Dunning, CTO
> DeepDyve
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.423 / Virus Database: 270.14.39/2470 - Release Date:
> 10/30/09 15:18:00


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

tmenzel

lang only depends on JDK 1.2?

Reply Threaded More More options
Print post
Permalink
hi.

i was wondering about the proposal statement:
  Lang relies only on standard JDK 1.2 (or later) APIs for production
  deployment.

doesnt that need to be updated to 1.5 b/c at least in ObjectUtils there is a method that uses generics?

so long
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Henri Yandell

Re: new feature: coalesce operator / method

Reply Threaded More More options
Print post
Permalink
In reply to this post by Ted Dunning
For the record - this went in as a merge with LANG-358.

On Sun, Nov 1, 2009 at 2:36 AM,  <[hidden email]> wrote:

> Done. See https://issues.apache.org/jira/browse/LANG-550
>
>
>
>> -----Original Message-----
>> From: Ted Dunning [mailto:[hidden email]]
>> Sent: Freitag, 30. Oktober 2009 20:56
>> To: Commons Users List
>> Subject: Re: new feature: coalesce operator / method
>>
>> Write up a JIRA and a patch and go for it!
>>
>> I would recommend that the name be "firstNonNull" rather than
>> "coalesce".
>> The verb coalesce implies things coming together rather than selecting
>> one
>> of many.
>>
>> On Fri, Oct 30, 2009 at 6:39 AM, thomas menzel
>> <[hidden email]>wrote:
>>
>> > hi,
>> >
>> > after writing an if (x != null) {o = ...} else if (y != null) {o = }
>> ...
>> > cascade, i just thought that we could use a coalesce operator in java
>> as
>> > well....
>> >
>> >
>> > until sun will support this i think this could be hosted somewhere in
>> the
>> > commons.lang package:
>> >
>> > Operators.coalesce(final Object... object);
>> >
>> > this then would return the first non-null objecet from the given
>> > list/array.
>> >
>> > alternatively this could also go on ObjectUtils.
>> >
>> > what do u think?
>> >
>> > --
>> > Neu: GMX DSL bis 50.000 kBit/s und 200,- Euro Startguthaben!
>> > http://portal.gmx.net/de/go/dsl02
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]
>> > For additional commands, e-mail: [hidden email]
>> >
>> >
>>
>>
>> --
>> Ted Dunning, CTO
>> DeepDyve
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com
>> Version: 8.5.423 / Virus Database: 270.14.39/2470 - Release Date:
>> 10/30/09 15:18:00
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Henri Yandell

Re: lang only depends on JDK 1.2?

Reply Threaded More More options
Print post
Permalink
In reply to this post by tmenzel
Thanks Thomas.

I've removed the PROPOSAL.html file as it's a file created before Lang
was created and I don't know what the value is in having it hang
around is.

Hen

On Mon, Nov 2, 2009 at 1:52 AM, thomas menzel <[hidden email]> wrote:

> hi.
>
> i was wondering about the proposal statement:
>  Lang relies only on standard JDK 1.2 (or later) APIs for production
>  deployment.
>
> doesnt that need to be updated to 1.5 b/c at least in ObjectUtils there is a method that uses generics?
>
> so long
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]