Comparator/Comparators API change proposal
henry.jen at oracle.com
Mon Jun 3 18:13:16 PDT 2013
On Jun 3, 2013, at 5:07 PM, Michael Hixson <michael.hixson at gmail.com> wrote:
> Hi Henry,
> 1. Does this code throw an NPE? It's not clear from the docs.
> int result = Comparators
> .compare(null, null);
It should return 0; otherwise, it's a bug.
> 2. How did you decide which static methods should live on Comparator
> versus Comparators?
Good question, it can be confusing.
The (compromised) idea is that commonly-use constructor-like factory method will be in Comparator; Otherwise, in Comparators. Anything take a Comparator to return a comparator(i.e. combinator) should be in Comparators with the exception of comparing(Function, Comparator).
I would like to hear if there are better suggestions.
> 3. There are a couple of awkward-sounding parts in the docs, e.g. "Try
> to compare null with returned comparator will throw
> NullPointerException." Do you want me (and/or others) to suggest
> concrete changes here, in this thread?
I am open for suggestions. Thanks for reviewing.
More information about the lambda-libs-spec-observers