RFR 8009736: Comparator API cleanup (original) (raw)

Paul Sandoz paul.sandoz at oracle.com
Wed Jun 12 14🔞09 UTC 2013


Hi Henry,

If you don't mind could you hold off on committing this one until the following have gone through to tl:

http://cr.openjdk.java.net/~psandoz/tl/JDK-8016251-spinedBuffer-splitr/webrev/ http://cr.openjdk.java.net/~psandoz/tl/JDK-8016308-Node/webrev/ http://cr.openjdk.java.net/~psandoz/tl/JDK-8016324-pipelines/webrev/ http://cr.openjdk.java.net/~psandoz/tl/JDK-8016455-stream-tests/webrev/

as there is a delicate balance here to group the code into meaningful units for review and it's awkward to shuffle/update things.

I rebased your patch off my patch queue, only one conflict required fixing. I can send you that queue in another email. Is that OK for you?

--

Comparator.reverseOrder

Typo "Try to compare" (and to . Do you mean:

The compare method of the returned comparator will throw a {@link NullPointerException} if a {@code null} value is passed as the second parameter.

?

Perhaps add a "@See Collections#reverseOrder" and vice versa on that method.

Similar issue for Comparator.naturalOrder but for null passed as the first parameter.

Comparators.comparing.

Rather than "For example" you can use @apiNote .e.g

The ToIntFunction accepting method has an example where as the long and double methods to not, perhaps just remove it.

Comparators.NullComparator

The "real" field can never be null:

but you are checking for null in the compare method

Map.comparingByKey/Value(Comparator<? super K/V> cmp)

You don't mention "Note that a null key/value..."

test/java/util/Comparator/BasicTest.java test/java/util/Comparator/TypeTest.java

Has the wrong license header:

should be:

Thanks, Paul.

On Jun 11, 2013, at 11:04 PM, Henry Jen <henry.jen at oracle.com> wrote:

Hi,

Please review http://cr.openjdk.java.net/~henryjen/ccc/8009736.2/webrev/ Highlight of changes, - Comparators class is now only package-private implementations. The public static methods have been move to other arguably more appropriate places, mostly in Comparator. - Comparator.reverseOrder() is renamed to Comparator.reversed() - nullsFirst(Comparator) and nullsLast(Comparator) are introduced to wrap up a comparator to be null-friendly. To see the API changes, found the specdiff at http://cr.openjdk.java.net/~henryjen/ccc/8009736.2/specdiff/overview-summary.html Cheers, Henry



More information about the core-libs-dev mailing list