lambda binary snapshots
Arul Dhesiaseelan
aruld at acm.org
Sun Nov 13 10:15:19 PST 2011
Thanks Brian, Ryan for the insight. It clears up so many things for me.
Now, I can play with it more to get used to with these new APIs.
On Sun, Nov 13, 2011 at 1:33 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
> in general, keep in mind that the library work is all completely
> speculative and may look nothing like the final product.
>
> Composing comparators allows you to impose a dictionary ordering. So:
>
> Comparator<Person> byLastName = comparing(Person::getLastName);
>
> Comparator<Person> byLastAndFirstName =
> byLastName.compose(comparing(Person::getFirstName));
>
> The second of these will compare by last and first name, that is, when
> last name is equal, it will resolve ties by comparing first name.
>
> Because this is an extension method, the receiver in the invocation
> becomes the first argument to the default:
>
> foo.compose(bar)
>
> becomes
>
> compose(foo, bar)
>
> when it is actually executed.
>
>
>
> On Nov 13, 2011, at 1:52 AM, Arul Dhesiaseelan wrote:
>
> > JDK 8 Lambda build is cool. Thanks for making this available!
> >
> > I was playing with defender methods, wondering what makes this scenario
> > work:
> >
> > In Comparator, there is a new default method compose() which has single
> > parameter:
> >
> > Comparator<T> compose(Comparator<? super T> other) default
> > Comparators.compose;
> >
> > The default implementation in Comparators has two parameters:
> >
> > public static<T> Comparator<T> compose(Comparator<T> first, Comparator<?
> > super T> second) {}
> >
> > For example, the woven class String.CASE_INSENSITIVE_ORDER
> > (CaseInsensitiveComparator.class) has single parameter. I am not sure I
> > understand how this works, need help.
> >
> > -Arul
> >
>
More information about the lambda-dev
mailing list