From feb7b2fe0cb315bc6f0d38dcb3fcf30462055347 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Sun, 28 Apr 2013 22:48:08 +0000 Subject: [PATCH] No need to exactly invert whatever value is returned, especially as the Javadoc says we only return -1, 0 or +1. This fixes Findbugs complaint about checking compareTo with a specific value, as well as avoiding a multiplication. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1476850 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/collections4/comparators/ComparatorChain.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java b/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java index 1fb7b66ec..7920434c3 100644 --- a/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java +++ b/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java @@ -278,10 +278,10 @@ public class ComparatorChain implements Comparator, Serializable { if (retval != 0) { // invert the order if it is a reverse sort if (orderingBits.get(comparatorIndex) == true) { - if (Integer.MIN_VALUE == retval) { - retval = Integer.MAX_VALUE; + if (retval > 0) { + retval = -1; } else { - retval *= -1; + retval = 1; } } return retval;