diff --git a/src/main/java/org/openrewrite/java/migrate/guava/NoGuavaSetsFilter.java b/src/main/java/org/openrewrite/java/migrate/guava/NoGuavaSetsFilter.java
new file mode 100644
index 0000000000..6343d0d6d2
--- /dev/null
+++ b/src/main/java/org/openrewrite/java/migrate/guava/NoGuavaSetsFilter.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2025 the original author or authors.
+ *
+ * Licensed under the Moderne Source Available License (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openrewrite.java.migrate.guava;
+
+import org.openrewrite.ExecutionContext;
+import org.openrewrite.Preconditions;
+import org.openrewrite.Recipe;
+import org.openrewrite.TreeVisitor;
+import org.openrewrite.java.JavaTemplate;
+import org.openrewrite.java.JavaVisitor;
+import org.openrewrite.java.MethodMatcher;
+import org.openrewrite.java.search.UsesMethod;
+import org.openrewrite.java.tree.J;
+
+import java.util.Set;
+
+import static java.util.Collections.singleton;
+
+public class NoGuavaSetsFilter extends Recipe {
+ private static final MethodMatcher SETS_FILTER = new MethodMatcher("com.google.common.collect.Sets filter(java.util.Set, com.google.common.base.Predicate)");
+ private static final MethodMatcher SETS_FILTER_SORTED_SET = new MethodMatcher("com.google.common.collect.Sets filter(java.util.SortedSet, com.google.common.base.Predicate)");
+
+ @Override
+ public String getDisplayName() {
+ return "Prefer `Collection.stream().filter(Predicate)`";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Prefer `Collection.stream().filter(Predicate)` over `Sets.filter(Set, Predicate)`.";
+ }
+
+ @Override
+ public Set getTags() {
+ return singleton("guava");
+ }
+
+ @Override
+ public TreeVisitor, ExecutionContext> getVisitor() {
+ TreeVisitor, ExecutionContext> precondition = Preconditions.or(new UsesMethod<>(SETS_FILTER), new UsesMethod<>(SETS_FILTER_SORTED_SET));
+ return Preconditions.check(precondition, new JavaVisitor() {
+ @Override
+ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
+ if (SETS_FILTER_SORTED_SET.matches(method)) {
+ maybeRemoveImport("com.google.common.base.Predicate");
+ maybeRemoveImport("com.google.common.collect.Sets");
+ maybeAddImport("java.util.TreeSet");
+ maybeAddImport("java.util.function.Predicate");
+ maybeAddImport("java.util.stream.Collectors");
+
+ return JavaTemplate.builder("#{any(java.util.Collection)}.stream().filter(#{any(java.util.function.Predicate)}).collect(Collectors.toCollection(TreeSet::new))")
+ .imports("java.util.TreeSet")
+ .imports("java.util.stream.Collectors")
+ .build()
+ .apply(getCursor(),
+ method.getCoordinates().replace(),
+ method.getArguments().get(0),
+ method.getArguments().get(1));
+ }
+ if (SETS_FILTER.matches(method)) {
+ maybeRemoveImport("com.google.common.base.Predicate");
+ maybeRemoveImport("com.google.common.collect.Sets");
+ maybeAddImport("java.util.TreeSet");
+ maybeAddImport("java.util.function.Predicate");
+ maybeAddImport("java.util.stream.Collectors");
+
+ return JavaTemplate.builder("#{any(java.util.Collection)}.stream().filter(#{any(java.util.function.Predicate)}).collect(Collectors.toSet())")
+ .imports("java.util.stream.Collectors")
+ .build()
+ .apply(getCursor(),
+ method.getCoordinates().replace(),
+ method.getArguments().get(0),
+ method.getArguments().get(1));
+ }
+ return super.visitMethodInvocation(method, ctx);
+ }
+ }
+ );
+ }
+}
diff --git a/src/main/resources/META-INF/rewrite/no-guava.yml b/src/main/resources/META-INF/rewrite/no-guava.yml
index 3b01ea22e2..ab7879a5ea 100644
--- a/src/main/resources/META-INF/rewrite/no-guava.yml
+++ b/src/main/resources/META-INF/rewrite/no-guava.yml
@@ -38,6 +38,7 @@ recipeList:
- org.openrewrite.java.migrate.guava.NoGuavaPrimitiveAsList
- org.openrewrite.java.migrate.guava.NoGuavaRefasterRecipes
- org.openrewrite.java.migrate.guava.NoGuavaMapsNewHashMap
+ - org.openrewrite.java.migrate.guava.NoGuavaSetsFilter
- org.openrewrite.java.migrate.guava.NoGuavaSetsNewHashSet
- org.openrewrite.java.migrate.guava.NoGuavaSetsNewConcurrentHashSet
- org.openrewrite.java.migrate.guava.NoGuavaSetsNewLinkedHashSet
diff --git a/src/test/java/org/openrewrite/java/migrate/guava/NoGuavaSetsFilterTest.java b/src/test/java/org/openrewrite/java/migrate/guava/NoGuavaSetsFilterTest.java
new file mode 100644
index 0000000000..e19e8587dc
--- /dev/null
+++ b/src/test/java/org/openrewrite/java/migrate/guava/NoGuavaSetsFilterTest.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2025 the original author or authors.
+ *
+ * Licensed under the Moderne Source Available License (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openrewrite.java.migrate.guava;
+
+import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.ExpectedToFail;
+import org.junitpioneer.jupiter.Issue;
+import org.openrewrite.DocumentExample;
+import org.openrewrite.InMemoryExecutionContext;
+import org.openrewrite.java.JavaParser;
+import org.openrewrite.test.RecipeSpec;
+import org.openrewrite.test.RewriteTest;
+
+import static org.openrewrite.java.Assertions.java;
+
+class NoGuavaSetsFilterTest implements RewriteTest {
+
+ @Override
+ public void defaults(RecipeSpec spec) {
+ spec
+ .recipe(new NoGuavaSetsFilter())
+ .parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "guava"));
+ }
+
+ @DocumentExample
+ @Test
+ void replaceSetsFilter() {
+ //language=java
+ rewriteRun(
+ java(
+ """
+ import java.util.Set;
+
+ import com.google.common.base.Predicate;
+ import com.google.common.collect.Sets;
+
+ class Test {
+ public static Set