From b203594ecd50df310bdf13f1ea05c319f616812b Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Thu, 11 May 2023 14:27:03 -0700 Subject: [PATCH] Add overloads that take `java.util.function.Predicate`s https://github.com/google/guava/pull/6483#discussion_r1190699366 PiperOrigin-RevId: 531307672 --- .../java/com/google/errorprone/CompilationTestHelper.java | 2 +- .../java/com/google/errorprone/DiagnosticTestHelper.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test_helpers/src/main/java/com/google/errorprone/CompilationTestHelper.java b/test_helpers/src/main/java/com/google/errorprone/CompilationTestHelper.java index 6a163747a1ff..c8e706aae16e 100644 --- a/test_helpers/src/main/java/com/google/errorprone/CompilationTestHelper.java +++ b/test_helpers/src/main/java/com/google/errorprone/CompilationTestHelper.java @@ -28,7 +28,6 @@ import static org.junit.Assert.fail; import com.google.common.base.Joiner; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.io.ByteStreams; import com.google.errorprone.DiagnosticTestHelper.LookForCheckNameInDiagnostic; @@ -52,6 +51,7 @@ import java.util.List; import java.util.Locale; import java.util.Optional; +import java.util.function.Predicate; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; import javax.annotation.Nullable; diff --git a/test_helpers/src/main/java/com/google/errorprone/DiagnosticTestHelper.java b/test_helpers/src/main/java/com/google/errorprone/DiagnosticTestHelper.java index e640ec6877af..f79e9ae44db5 100644 --- a/test_helpers/src/main/java/com/google/errorprone/DiagnosticTestHelper.java +++ b/test_helpers/src/main/java/com/google/errorprone/DiagnosticTestHelper.java @@ -23,7 +23,6 @@ import static org.hamcrest.Matchers.hasItem; import static org.junit.Assert.fail; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import com.google.common.io.CharSource; @@ -38,6 +37,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.function.Predicate; import java.util.stream.Collectors; import javax.tools.Diagnostic; import javax.tools.DiagnosticListener; @@ -195,7 +195,7 @@ public boolean matchesSafely( return false; } - if (!matcher.apply(item.getMessage(Locale.getDefault()))) { + if (!matcher.test(item.getMessage(Locale.getDefault()))) { mismatchDescription.appendText("diagnostic does not match ").appendValue(matcher); return false; } @@ -400,7 +400,7 @@ private static class SimpleStringContains implements Predicate { } @Override - public boolean apply(String input) { + public boolean test(String input) { return input.contains(pattern); }