CFR - updated 8001667: Comparator combinators and extension methods

Paul Sandoz paul.sandoz at oracle.com
Wed Mar 6 01:51:36 PST 2013


Hi Henry,

Minor thing.

In Comparator:

 194      * @param other the other comparator used when equals on this.
 195      * @throws NullPointerException if the argument is null.
 196      * @since 1.8
 197      */
 198     default Comparator<T> thenComparing(Comparator<? super T> other) {
 199         return Comparators.compose(this, other);
 200     }

Perhaps:

@param other the other comparator to be used when this comparator compares two objects that are equal
@throws NullPointerException if the argument is null.
@since 1.8
@return A lexicographic order comparator composed of this and then the other comparator


In Comparators:

 241      * @param <T> the element type to be compared
 242      * @param first the first comparator
 243      * @param second the secondary comparator used when equals on the first
 244      */
 245     public static<T> Comparator<T> compose(Comparator<? super T> first, Comparator<? super T> second) {
 246         Objects.requireNonNull(first);
 247         Objects.requireNonNull(second);
 248         return (Comparator<T> & Serializable) (c1, c2) -> {
 249             int res = first.compare(c1, c2);
 250             return (res != 0) ? res : second.compare(c1, c2);
 251         };
 252     }

@param second the second comparator to be used when the first comparator compares two objects that are equal
@return A lexicographic order comparator composed of the first and then the second comparator

Paul.

On Mar 5, 2013, at 8:46 PM, Henry Jen <henry.jen at oracle.com> wrote:

> Hi,
> 
> Another update to reflect functional interface renames involved in the
> API, and a bug fix for a regression found earlier.
> 
> CCC had been approved. Can we get it reviewed and pushed?
> 
> [1] http://cr.openjdk.java.net/~henryjen/ccc/8001667.4/webrev
> 
> Cheers,
> Henry



More information about the lambda-dev mailing list