Package org.openrewrite
Class Recipe
java.lang.Object
org.openrewrite.Recipe
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ChangeText,CompositeRecipe,DeclarativeRecipe,DeleteSourceFiles,EndOfLineAtEndOfFile,Find,FindAndReplace,FindBuildToolFailures,FindParseFailures,FindQuarks,FindSourceFiles,RenameFile,ScanningRecipe,SetFilePermissions
Provides a formalized link list data structure of
recipes and a run(LargeSourceSet, ExecutionContext) method which will
apply each recipes visitor visit method to a list of sourceFiles
Requires a name, visitor.
Optionally a subsequent Recipe can be linked via getRecipeList()}
An ExecutionContext controls parallel execution and lifecycle while providing a message bus
for sharing state between recipes and their visitors
returns a list of results for each modified SourceFile
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<Contributor>protected List<RecipeExample>static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataTable(DataTable<?> dataTable) booleanclone()protected RecipeDescriptorbooleanabstract StringA human-readable description for the recipe, consisting of one or more full sentences ending with a period.final RecipeDescriptorabstract StringA human-readable display name for the recipe, initial capped with no period.getName()A list of recipes that run, source file by source file, after this recipe.getTags()A set of strings used for categorizing related recipes.A recipe can optionally encapsulate a visitor that performs operations on a set of source files.inthashCode()intstatic Recipenoop()final RecipeRunrun(LargeSourceSet before, ExecutionContext ctx) final RecipeRunrun(LargeSourceSet before, ExecutionContext ctx, int maxCycles) final RecipeRunrun(LargeSourceSet before, ExecutionContext ctx, int maxCycles, int minCycles) validate()The default implementation of validate on the recipe will look for package and field level annotations that indicate a field is not-null.validate(ExecutionContext ctx) final Collection<Validated<Object>>
-
Field Details
-
PANIC
- See Also:
-
contributors
-
examples
-
-
Constructor Details
-
Recipe
public Recipe()
-
-
Method Details
-
getJacksonPolymorphicTypeTag
-
noop
-
maxCycles
- Returns:
- The maximum number of cycles this recipe is allowed to make changes in a recipe run.
-
getDisplayName
A human-readable display name for the recipe, initial capped with no period. For example, "Find text". The display name can be assumed to be rendered in documentation and other places where markdown is understood, so it is possible to use stylistic markers like backticks to indicate types. For example, "Find uses of `java.util.List`".- Returns:
- The display name.
-
getDescription
A human-readable description for the recipe, consisting of one or more full sentences ending with a period."Find methods by pattern." is an example. The description can be assumed to be rendered in documentation and other places where markdown is understood, so it is possible to use stylistic markers like backticks to indicate types. For example, "Find uses of `java.util.List`.".
- Returns:
- The display name.
-
getTags
A set of strings used for categorizing related recipes. For example "testing", "junit", "spring". Any individual tag should consist of a single word, all lowercase.- Returns:
- The tags.
-
getEstimatedEffortPerOccurrence
- Returns:
- An estimated effort were a developer to fix manually instead of using this recipe.
-
getDescriptor
-
createRecipeDescriptor
-
getDataTableDescriptors
-
getMaintainers
- Returns:
- a list of the organization(s) responsible for maintaining this recipe.
-
getContributors
-
getExamples
-
causesAnotherCycle
public boolean causesAnotherCycle()- Returns:
- Determines if another cycle is run when this recipe makes a change. In some cases, like changing method declaration names, a further cycle is needed to update method invocations of that declaration that were visited prior to the declaration change. But other visitors never need to cause another cycle, such as those that format whitespace or add search markers. Note that even when this is false, the recipe will still run on another cycle if any other recipe causes another cycle to run. But if every recipe reports no need to run another cycle (or if there are no changes made in a cycle), then another will not run.
-
getRecipeList
A list of recipes that run, source file by source file, after this recipe. This method is guaranteed to be called only once per cycle.- Returns:
- The list of recipes to run.
-
getVisitor
A recipe can optionally encapsulate a visitor that performs operations on a set of source files. Subclasses of the recipe may override this method to provide an instance of a visitor that will be used when the recipe is executed.- Returns:
- A tree visitor that will perform operations associated with the recipe.
-
addDataTable
-
run
-
run
-
run
public final RecipeRun run(LargeSourceSet before, ExecutionContext ctx, int maxCycles, int minCycles) -
validate
-
validate
The default implementation of validate on the recipe will look for package and field level annotations that indicate a field is not-null. The annotations must have run-time retention and the simple name of the annotation must match one of the common names defined inNullUtils- Returns:
- A validated instance based using non-null/nullable annotations to determine which fields of the recipe are required.
-
validateAll
-
getName
-
equals
-
hashCode
public int hashCode() -
clone
-