Class Recipe

    • Constructor Detail

      • Recipe

        public Recipe()
    • Method Detail

      • getJacksonPolymorphicTypeTag

        public java.lang.String getJacksonPolymorphicTypeTag()
      • getDisplayName

        public abstract java.lang.String 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

        public java.lang.String 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

        public java.util.Set<java.lang.String> getTags()
        A set of strings used for categorizing related recipes. For example "testing", "junit", "spring". Tags should not include information about the language(s) this recipe is applicable to. See getLanguages() instead. Any individual tag should consist of a single word, all lowercase.
        Returns:
        The tags.
      • getEstimatedEffortPerOccurrence

        @Nullable
        public @Nullable java.time.Duration getEstimatedEffortPerOccurrence()
        Returns:
        An estimated effort were a developer to fix manually instead of using this recipe.
      • getLanguages

        public java.util.List<java.lang.String> getLanguages()
        Returns:
        Describes the language type(s) that this recipe applies to, e.g. java, xml, properties.
      • causesAnotherCycle

        @Incubating(since="7.3.0")
        public boolean causesAnotherCycle()
        Returns:
        Determines if another cycle is ran 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.
      • doNext

        public Recipe doNext​(Recipe recipe)
        Parameters:
        recipe - Recipe to add to this recipe's pipeline.
        Returns:
        This recipe.
      • getRecipeList

        public java.util.List<Recipe> getRecipeList()
      • getVisitor

        protected TreeVisitor<?,​ExecutionContext> getVisitor()
        A recipe can optionally encasulate 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.
      • getApplicableTest

        @Incubating(since="7.2.0")
        @Nullable
        protected @Nullable TreeVisitor<?,​ExecutionContext> getApplicableTest()
        A recipe can optionally include an applicability test that can be used to determine whether it should run on a set of source files (or even be listed in a suggested list of recipes for a particular codebase).

        To identify a tree as applicable, the visitor should mark or otherwise any tree at any level. Any mutation that the applicability test visitor makes to a tree will not included in the results.

        Returns:
        A tree visitor that performs an applicability test.
      • getSingleSourceApplicableTest

        @Incubating(since="7.4.0")
        @Nullable
        protected @Nullable TreeVisitor<?,​ExecutionContext> getSingleSourceApplicableTest()
        A recipe can optionally include an applicability test that can be used to determine whether it should run on a particular source file.

        To identify a SourceFile as applicable, the visitor should mark it at any level. Any mutation that the applicability test visitor makes on the tree will not included in the results.

        The applicability test only affects whether this recipes getVisitor() will run. Downstream doNext(Recipe) will still run.

        Returns:
        A tree visitor that performs an applicability test.
      • visit

        protected java.util.List<SourceFile> visit​(java.util.List<SourceFile> before,
                                                   ExecutionContext ctx)
        Override this to generate new source files or delete source files.
        Parameters:
        before - The set of source files to operate on.
        ctx - The current execution context.
        Returns:
        A set of source files, with some files potentially added/deleted/modified.
      • run

        public final java.util.List<Result> run​(java.util.List<? extends SourceFile> before)
      • validate

        public Validated 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 in NullUtils
        Returns:
        A validated instance based using non-null/nullable annotations to determine which fields of the recipe are required.
      • validateAll

        public final java.util.Collection<Validated> validateAll()
      • getName

        public java.lang.String getName()
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object