Guess What I'm Up To...

Published 23 March 07 05:18 AM | andersnoras 

I mentioned in a recent post that I would be doing more Java-related work in the days to come. Its been a while since last I did any serious Java-stuff, so I felt that I needed to play around a little to catch up with new features and idioms. I did a small spike today to play around with the new features in J2SE 1.5. Can anybody guess what this is?

@Test
public void canSelectAllNumbersLessThanN()
{
    Integer[] numbers={ 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
    Iterable<Integer> lowNumbers=
              from(numbers).where(lt(5)).select();
    for (Integer number : lowNumbers)
    {
        assertTrue(number<5);
    }
}

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Ayende Rahien said on March 23, 2007 4:24 PM:

Very nice, the only bad part is that you have to use a base class to expose this functionality.

# andersnoras said on March 23, 2007 11:23 PM:

Actually I don't. This is based on the new static imports feature in J2SE 1.5 - the LINQish DSL is defined in a separate JAR and imported with

import static com.noras.junq.QuerySupport.*

# Ayende Rahien said on March 27, 2007 7:31 AM:

Wow, didn't know that Java had this.

Very nice.

# Anders Norås' Blog said on April 26, 2007 6:22 AM:

Lately I've been playing around with embedded DSLs for Java. Regular readers might remember my little

# Anders Norås' Blog said on May 23, 2007 11:53 AM:

I just got an email from the program committee for the JavaZone conference confirming that my proposed

# Anders Norås' Blog said on May 29, 2007 3:44 PM:

I've been putting some more work into my little Linq for Java demo lately to make the tests for all the

# Anders Norås' Blog said on July 15, 2007 3:11 PM:

My latest posts on DSLs caused a bit of a stir around the blogosphere. Some of of the more constructive

Leave a Comment

(required) 
(optional)
(required) 
Enter the code you see below