Skip to content

Commit a53e8d1

Browse files
committed
Prevent class cast exception in NoGuavaPredicate
1 parent a9e5728 commit a53e8d1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/main/java/org/openrewrite/java/migrate/guava/NoGuavaPredicate.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,20 @@ public String getDescription() {
4040
public TreeVisitor<?, ExecutionContext> getVisitor() {
4141
return Preconditions.check(
4242
Preconditions.not(new UsesPredicateMethod<>()),
43-
new TreeVisitor<Tree, ExecutionContext>() {
43+
new JavaIsoVisitor<ExecutionContext>() {
4444
@Override
45-
public Tree preVisit(Tree tree, ExecutionContext ctx) {
46-
Tree t = tree;
47-
t = new ChangeMethodName(
45+
public J preVisit(J java, ExecutionContext ctx) {
46+
J j = (J) new ChangeMethodName(
4847
"com.google.common.base.Predicate apply(..)",
4948
"test",
5049
true,
5150
false
52-
).getVisitor().visitNonNull(t, ctx, getCursor().getParentOrThrow());
53-
return new ChangeType(
51+
).getVisitor().visitNonNull(java, ctx, getCursor().getParentOrThrow());
52+
return (J) new ChangeType(
5453
"com.google.common.base.Predicate",
5554
"java.util.function.Predicate",
5655
false
57-
).getVisitor().visitNonNull(t, ctx, getCursor().getParentOrThrow());
56+
).getVisitor().visitNonNull(j, ctx, getCursor().getParentOrThrow());
5857
}
5958
}
6059
);

0 commit comments

Comments
 (0)