Bikeshed opportunity: compose vs composeWith (original) (raw)
Brian Goetz brian.goetz at oracle.com
Mon Nov 26 14:56:17 PST 2012
- Previous message: Bikeshed opportunity: compose vs composeWith
- Next message: Bikeshed opportunity: compose vs composeWith
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This would be cool to read, but is a different animal.
people.sortBy(Person::getLast).thenBy(Person::getFirst)
Right. See exchange last week about the combinatorial explosion when we tried this.
We use the word "chain" on our Comparators static utility class in GS Collections with varargs. But since you are adding this method to Comparator, not sure if chain or chainWith would be a good name.
Seems a possibility.
What about this?
people.sort(comparing(Person::getLast).thenBy(Person::getFirst))
At first I thought this was "same as above", but now that I think about it more it is possible. This would involve overloading:
thenBy(Comparator)
with
thenBy(Function<T,U extends Comparable>) thenBy(IntFunction)
in Comparator.
It also looks OK outside the sort example:
Comparator byFirstLast = byLast.thenBy(Person::getFirst);
- Previous message: Bikeshed opportunity: compose vs composeWith
- Next message: Bikeshed opportunity: compose vs composeWith
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-observers mailing list