Skip to content

Commit

Permalink
Add preconditions to quickly limit when recipes will run
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Jan 19, 2025
1 parent bbbefc0 commit e5d439d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Preconditions;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.JavaParser;
import org.openrewrite.java.JavaTemplate;
import org.openrewrite.java.search.UsesType;
import org.openrewrite.java.tree.J;

import static java.util.Comparator.comparing;
Expand All @@ -45,7 +47,10 @@ public String getDescription() {

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
return new Summarizer();
return Preconditions.check(
new UsesType<>("lombok.Getter", false),
new Summarizer()
);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Preconditions;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.JavaParser;
import org.openrewrite.java.JavaTemplate;
import org.openrewrite.java.search.UsesType;
import org.openrewrite.java.tree.J;

import static java.util.Comparator.comparing;
Expand All @@ -45,7 +47,10 @@ public String getDescription() {

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
return new Summarizer();
return Preconditions.check(
new UsesType<>("lombok.Setter", false),
new Summarizer()
);
}


Expand Down

0 comments on commit e5d439d

Please sign in to comment.