1515 */
1616package org .openrewrite .java .migrate .joda ;
1717
18- import lombok .EqualsAndHashCode ;
1918import lombok .Getter ;
20- import lombok .Value ;
2119import org .jspecify .annotations .Nullable ;
22- import org .openrewrite .*;
20+ import org .openrewrite .ExecutionContext ;
21+ import org .openrewrite .Preconditions ;
22+ import org .openrewrite .ScanningRecipe ;
23+ import org .openrewrite .TreeVisitor ;
2324import org .openrewrite .java .search .UsesType ;
2425import org .openrewrite .java .tree .J ;
2526import org .openrewrite .java .tree .J .VariableDeclarations .NamedVariable ;
2930
3031import static java .util .Collections .emptyList ;
3132
32- @ EqualsAndHashCode (callSuper = false )
33- @ Value
3433public class JodaTimeRecipe extends ScanningRecipe <JodaTimeRecipe .Accumulator > {
35-
36- /**
37- * Controls whether additional safety checks are performed during the migration process.
38- * When enabled, the recipe will verify that expressions are safe to migrate before performing the migration.
39- * This helps prevent potential issues or bugs that might arise from automatic migration.
40- */
41- @ Option (displayName = "Safe migration only" ,
42- description = "When enabled, performs additional safety checks to verify that expressions are safe to migrate before converting them. " +
43- "Safety checks include analyzing method parameters, return values, and variable usages across class boundaries." ,
44- required = false
45- )
46- @ Nullable
47- Boolean safeMigrationOnly ;
48-
4934 @ Override
5035 public String getDisplayName () {
5136 return "Migrate Joda-Time to Java time" ;
@@ -63,12 +48,12 @@ public Accumulator getInitialValue(ExecutionContext ctx) {
6348
6449 @ Override
6550 public TreeVisitor <?, ExecutionContext > getScanner (Accumulator acc ) {
66- return new JodaTimeScanner (acc , Boolean . TRUE . equals ( safeMigrationOnly ) );
51+ return new JodaTimeScanner (acc );
6752 }
6853
6954 @ Override
7055 public TreeVisitor <?, ExecutionContext > getVisitor (Accumulator acc ) {
71- JodaTimeVisitor jodaTimeVisitor = new JodaTimeVisitor (acc , Boolean . TRUE . equals ( safeMigrationOnly ) , new LinkedList <>());
56+ JodaTimeVisitor jodaTimeVisitor = new JodaTimeVisitor (acc , true , new LinkedList <>());
7257 return Preconditions .check (new UsesType <>("org.joda.time.*" , true ), jodaTimeVisitor );
7358 }
7459
0 commit comments