Class ChangePackageExcludingTypes

java.lang.Object
org.openrewrite.Recipe
org.axonframework.migration.ChangePackageExcludingTypes
All Implemented Interfaces:
Cloneable

public class ChangePackageExcludingTypes extends org.openrewrite.Recipe
Moves a package like OpenRewrite's ChangePackage, but keeps the given types in the old package.

A file referencing nothing of the old package but excluded types is left alone. Any other file is moved by ChangePackage, after which the excluded types are moved back with ChangeType. Running ChangePackage and a ChangeType back as two steps of a composite recipe instead moves an excluded type back and forth in every cycle of a run, so the run never settles.

Since:
5.4.0
Author:
Mateusz Nowak
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.openrewrite.Recipe

    org.openrewrite.Recipe.Builder, org.openrewrite.Recipe.DelegatingRecipe
  • Field Summary

    Fields inherited from class org.openrewrite.Recipe

    contributors, examples, PANIC
  • Constructor Summary

    Constructors
    Constructor
    Description
    ChangePackageExcludingTypes(String oldPackageName, String newPackageName, @Nullable Boolean recursive, @Nullable List<String> excludedTypes)
    Creates the recipe moving the given package, keeping the given types in it.
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    Returns the types of the old package this recipe keeps in it.
    Returns the package this recipe moves to.
    Returns the package this recipe moves.
    @Nullable Boolean
    Returns whether this recipe moves the subpackages too.
    org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext>
     

    Methods inherited from class org.openrewrite.Recipe

    addDataTable, aggregateDataTableDescriptors, builder, buildRecipeList, causesAnotherCycle, clone, createRecipeDescriptor, equals, getContributors, getDataTableDescriptors, getDescriptor, getEstimatedEffortPerOccurrence, getExamples, getInstanceName, getInstanceNameSuffix, getJacksonPolymorphicTypeTag, getMaintainers, getName, getRecipeList, getTags, hashCode, maxCycles, noop, onComplete, run, run, run, setContributors, setExamples, validate, validate, validateAll, validateAll, withOptions

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ChangePackageExcludingTypes

      public ChangePackageExcludingTypes(String oldPackageName, String newPackageName, @Nullable Boolean recursive, @Nullable List<String> excludedTypes)
      Creates the recipe moving the given package, keeping the given types in it.
      Parameters:
      oldPackageName - the package to move
      newPackageName - the package to move to
      recursive - whether to move the subpackages too, false when null
      excludedTypes - the fully qualified names of the types of the old package that stay in it, none when null
  • Method Details

    • getOldPackageName

      public String getOldPackageName()
      Returns the package this recipe moves.
      Returns:
      the old package name
    • getNewPackageName

      public String getNewPackageName()
      Returns the package this recipe moves to.
      Returns:
      the new package name
    • getRecursive

      public @Nullable Boolean getRecursive()
      Returns whether this recipe moves the subpackages too.
      Returns:
      whether subpackages move, or null for the default of not moving them
    • getExcludedTypes

      public List<String> getExcludedTypes()
      Returns the types of the old package this recipe keeps in it.
      Returns:
      the fully qualified names of the excluded types
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in class org.openrewrite.Recipe
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in class org.openrewrite.Recipe
    • getVisitor

      public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()
      Overrides:
      getVisitor in class org.openrewrite.Recipe