Comparator/Comparators API change proposal

Stephen Colebourne scolebourne at joda.org
Tue Jun 4 02:10:22 PDT 2013


On 3 June 2013 22:33, Henry Jen <henry.jen at oracle.com> wrote:
> 2. rename Comparator.reverseOrder() default method to reverse(), it's
> simply reverse form of the comparator.

I would recommend reversed().

reverse() implies you are changing a property of the comparator, in a
mutable style. reversed() implies that you are returning a new
comparator in an immutable style.

list.sort( comparing(Person::getLastName).reversed() );

See "past tense" in http://blog.joda.org/2011/08/common-java-method-names.html

Stephen


More information about the lambda-dev mailing list