Request for Review: CR#8001667: Comparators class and Comparator extension method

Henry Jen henry.jen at oracle.com
Tue Nov 13 20:09:23 PST 2012


Hi,

This is a change set regarding Comparator already in lambda repo, it
depends on the CR#8001634, particularly the Function SAMs.

It implements proposed extension methods on Comparator
(reverse and compose) as well as static combinator methods in
Comparators for things like turning a T -> {Comparable,int,long,double}
into a Comparator<T>.

This allows things like:

   people.sort(Comparators.comparing(Person::getName))
   Comparator<Person> byLastFirst
       = Comparators.comparing(Person::getLastName)
                   .compose(Comparators.comparing(Person::getFirstName))

Please review and comment on the webrev[1].

[1] http://cr.openjdk.java.net/~henryjen/webrevs/8001667.0/

Cheers,
Henry


More information about the lambda-dev mailing list