From a5a718974dd7d325025ea14c1492f113490d5cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89amonn=20McManus?= Date: Wed, 28 Aug 2024 09:04:18 -0700 Subject: [PATCH] Replace `ComparisonChain` with a `Comparator` chain. PiperOrigin-RevId: 668477671 --- .../com/google/errorprone/fixes/Replacements.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/check_api/src/main/java/com/google/errorprone/fixes/Replacements.java b/check_api/src/main/java/com/google/errorprone/fixes/Replacements.java index 44ca3f5dcf2..32acd7fd108 100644 --- a/check_api/src/main/java/com/google/errorprone/fixes/Replacements.java +++ b/check_api/src/main/java/com/google/errorprone/fixes/Replacements.java @@ -19,9 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument; import com.google.common.base.Joiner; -import com.google.common.collect.ComparisonChain; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Ordering; import com.google.common.collect.Range; import com.google.common.collect.RangeMap; import com.google.common.collect.TreeRangeMap; @@ -41,15 +39,9 @@ public class Replacements { * length of the input don't affect the position of earlier replacements. */ private static final Comparator> DESCENDING = - new Comparator>() { - @Override - public int compare(Range o1, Range o2) { - return ComparisonChain.start() - .compare(o1.lowerEndpoint(), o2.lowerEndpoint(), Ordering.natural().reverse()) - .compare(o1.upperEndpoint(), o2.upperEndpoint(), Ordering.natural().reverse()) - .result(); - } - }; + Comparator., Integer>comparing(Range::lowerEndpoint) + .thenComparing(Range::upperEndpoint) + .reversed(); private final TreeMap, Replacement> replacements = new TreeMap<>(DESCENDING); private final RangeMap overlaps = TreeRangeMap.create();