aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBrad Corso <bcorso@google.com>2021-11-12 11:36:01 -0800
committerGoogle Java Core Libraries <java-libraries-firehose+copybara@google.com>2021-11-12 11:36:44 -0800
commit102506c383e4e8165a1d8e23247549915d3ebcfb (patch)
tree0758ec5775ae8749a0e3a0b0e02771143e221581 /common
parentd6d9657feadae88134a6817df541796cf86a4356 (diff)
downloadauto-102506c383e4e8165a1d8e23247549915d3ebcfb.tar.gz
Remove usage of Guava 30 API (Comparators.min).
This CL removes the only Guava 30 usage in auto-common, Comparators.min. Motivation for change: Currently when writing annotation processors in Bazel, the Guava version is pinned to the version used by JavaBuilder. For the latest Bazel release, 4.2.1, this version is pinned to Guava 29, which means we can't use the latest auto-common in our annotation processors due to the usage of Comparators.min. Fwiw, Bazel 5.0 upgrades to Guava 30, but that version is still in the pre-release phase. RELNOTES=Remove usage of Guava 30 API (Comparators.min). PiperOrigin-RevId: 409461735
Diffstat (limited to 'common')
-rw-r--r--common/src/main/java/com/google/auto/common/Visibility.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/common/src/main/java/com/google/auto/common/Visibility.java b/common/src/main/java/com/google/auto/common/Visibility.java
index 36f4ad6d..db15f8bd 100644
--- a/common/src/main/java/com/google/auto/common/Visibility.java
+++ b/common/src/main/java/com/google/auto/common/Visibility.java
@@ -16,10 +16,10 @@
package com.google.auto.common;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Comparators.min;
import static javax.lang.model.element.ElementKind.PACKAGE;
import com.google.common.base.Enums;
+import com.google.common.collect.Ordering;
import java.util.Set;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
@@ -77,7 +77,9 @@ public enum Visibility {
Visibility effectiveVisibility = PUBLIC;
Element currentElement = element;
while (currentElement != null) {
- effectiveVisibility = min(effectiveVisibility, ofElement(currentElement));
+ // NOTE: We don't use Guava's Comparators.min() because that requires Guava 30, which would
+ // make this library unusable in annotation processors using Bazel < 5.0.
+ effectiveVisibility = Ordering.natural().min(effectiveVisibility, ofElement(currentElement));
currentElement = currentElement.getEnclosingElement();
}
return effectiveVisibility;