Skip to content

Commit 35f0472

Browse files
committed
Apply formatter
1 parent 3b72ea0 commit 35f0472

File tree

11 files changed

+27
-22
lines changed

11 files changed

+27
-22
lines changed

src/main/java/org/openrewrite/java/migrate/javax/AddColumnAnnotation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations m
9090

9191
// Update existing @Column annotation
9292
J.VariableDeclarations updatedVariable = (J.VariableDeclarations) new AddOrUpdateAnnotationAttribute(
93-
"javax.persistence.Column", "name", "element", true)
93+
"javax.persistence.Column", "name", "element", true, null)
9494
.getVisitor().visit(multiVariable, ctx, getCursor().getParentTreeCursor());
9595
return super.visitVariableDeclarations(updatedVariable, ctx);
9696
}

src/main/java/org/openrewrite/java/migrate/joda/JodaTimeRecipe.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.openrewrite.java.migrate.joda;
1717

1818
import lombok.Getter;
19+
import org.jspecify.annotations.Nullable;
1920
import org.openrewrite.ExecutionContext;
2021
import org.openrewrite.ScanningRecipe;
2122
import org.openrewrite.java.tree.J;
@@ -61,17 +62,17 @@ static class VarTable {
6162

6263
public void addVars(J.MethodDeclaration methodDeclaration) {
6364
JavaType type = methodDeclaration.getMethodType();
64-
65+
assert type != null;
6566
methodDeclaration.getParameters().forEach(p -> {
66-
if (!(p instanceof J.VariableDeclarations) ) {
67+
if (!(p instanceof J.VariableDeclarations)) {
6768
return;
6869
}
6970
J.VariableDeclarations.NamedVariable namedVariable = ((J.VariableDeclarations) p).getVariables().get(0);
7071
vars.computeIfAbsent(type, k -> new ArrayList<>()).add(namedVariable);
7172
});
7273
}
7374

74-
public NamedVariable getVarByName(JavaType declaringType, String varName) {
75+
public @Nullable NamedVariable getVarByName(@Nullable JavaType declaringType, String varName) {
7576
return vars.getOrDefault(declaringType, Collections.emptyList()).stream()
7677
.filter(v -> v.getSimpleName().equals(varName))
7778
.findFirst() // there should be only one variable with the same name

src/main/java/org/openrewrite/java/migrate/joda/JodaTimeScanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ private Optional<Cursor> findArgumentExprCursor() {
248248
while (cursor.getValue() instanceof Expression && isJodaExpr(cursor.getValue())) {
249249
Cursor parentCursor = cursor.getParentTreeCursor();
250250
if (parentCursor.getValue() instanceof MethodCall &&
251-
((MethodCall) parentCursor.getValue()).getArguments().contains(cursor.getValue())) {
251+
((MethodCall) parentCursor.getValue()).getArguments().contains(cursor.getValue())) {
252252
return Optional.of(cursor);
253253
}
254254
cursor = parentCursor;

src/main/java/org/openrewrite/java/migrate/joda/JodaTimeVisitor.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@
1919
import org.jspecify.annotations.Nullable;
2020
import org.openrewrite.ExecutionContext;
2121
import org.openrewrite.java.JavaTemplate;
22-
import org.openrewrite.java.migrate.joda.templates.*;
22+
import org.openrewrite.java.migrate.joda.templates.AllTemplates;
23+
import org.openrewrite.java.migrate.joda.templates.MethodTemplate;
24+
import org.openrewrite.java.migrate.joda.templates.TimeClassMap;
25+
import org.openrewrite.java.migrate.joda.templates.VarTemplates;
2326
import org.openrewrite.java.tree.*;
2427
import org.openrewrite.java.tree.J.VariableDeclarations.NamedVariable;
25-
import org.openrewrite.java.tree.MethodCall;
2628

27-
import java.util.*;
29+
import java.util.LinkedList;
30+
import java.util.List;
31+
import java.util.Optional;
2832

2933
import static org.openrewrite.java.migrate.joda.templates.TimeClassNames.*;
3034

@@ -33,7 +37,7 @@ public class JodaTimeVisitor extends ScopeAwareVisitor {
3337
private final boolean safeMigration;
3438
private final JodaTimeRecipe.Accumulator acc;
3539

36-
public JodaTimeVisitor(JodaTimeRecipe.Accumulator acc, boolean safeMigration, LinkedList<VariablesInScope> scopes) {
40+
public JodaTimeVisitor(JodaTimeRecipe.Accumulator acc, boolean safeMigration, LinkedList<VariablesInScope> scopes) {
3741
super(scopes);
3842
this.acc = acc;
3943
this.safeMigration = safeMigration;
@@ -96,14 +100,14 @@ public JodaTimeVisitor() {
96100
if (!variable.getType().isAssignableFrom(JODA_CLASS_PATTERN)) {
97101
return super.visitVariable(variable, ctx);
98102
}
99-
if (acc.getUnsafeVars().contains(variable) || ! (variable.getType() instanceof JavaType.Class)) {
103+
if (acc.getUnsafeVars().contains(variable) || !(variable.getType() instanceof JavaType.Class)) {
100104
return variable;
101105
}
102106
JavaType.Class jodaType = (JavaType.Class) variable.getType();
103107
return variable
104108
.withType(TimeClassMap.getJavaTimeType(jodaType.getFullyQualifiedName()))
105109
.withInitializer((Expression) visit(variable.getInitializer(), ctx));
106-
}
110+
}
107111

108112
@Override
109113
public @NonNull J visitAssignment(@NonNull J.Assignment assignment, @NonNull ExecutionContext ctx) {
@@ -243,7 +247,7 @@ private boolean isJodaVarRef(@Nullable Expression expr) {
243247
}
244248

245249
private boolean isArgument(J expr) {
246-
if ( !(getCursor().getParentTreeCursor().getValue() instanceof MethodCall)) {
250+
if (!(getCursor().getParentTreeCursor().getValue() instanceof MethodCall)) {
247251
return false;
248252
}
249253
MethodCall methodCall = getCursor().getParentTreeCursor().getValue();

src/main/java/org/openrewrite/java/migrate/joda/ScopeAwareVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import java.util.Set;
3030

3131
@AllArgsConstructor
32-
public class ScopeAwareVisitor extends JavaVisitor<ExecutionContext> {
32+
public class ScopeAwareVisitor extends JavaVisitor<ExecutionContext> {
3333
protected final LinkedList<VariablesInScope> scopes;
3434

3535
@Override

src/main/java/org/openrewrite/java/migrate/joda/templates/AbstractDurationTemplates.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
15-
*/package org.openrewrite.java.migrate.joda.templates;
15+
*/
16+
package org.openrewrite.java.migrate.joda.templates;
1617

1718
import lombok.Getter;
1819
import org.openrewrite.java.JavaTemplate;

src/main/java/org/openrewrite/java/migrate/joda/templates/AllTemplates.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import lombok.Value;
1919
import org.openrewrite.java.MethodMatcher;
20-
import org.openrewrite.java.tree.J;
2120
import org.openrewrite.java.tree.MethodCall;
2221

2322
import java.util.ArrayList;
@@ -39,7 +38,7 @@ public class AllTemplates {
3938
private static final MethodMatcher ANY_ABSTRACT_DATE_TIME = new MethodMatcher(JODA_ABSTRACT_DATE_TIME + " *(..)");
4039
private static final MethodMatcher ANY_ABSTRACT_DURATION = new MethodMatcher(JODA_ABSTRACT_DURATION + " *(..)");
4140
private static final MethodMatcher ANY_INSTANT = new MethodMatcher(JODA_INSTANT + " *(..)");
42-
private static final MethodMatcher ANY_NEW_INSTANT = new MethodMatcher(JODA_INSTANT + "<constructor>(..)");
41+
private static final MethodMatcher ANY_NEW_INSTANT = new MethodMatcher(JODA_INSTANT + "<constructor>(..)");
4342

4443
private static List<MatcherAndTemplates> templates = new ArrayList<MatcherAndTemplates>() {
4544
{

src/main/java/org/openrewrite/java/migrate/joda/templates/DurationTemplates.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import static org.openrewrite.java.migrate.joda.templates.TimeClassNames.*;
2828

2929
@NoArgsConstructor
30-
public class DurationTemplates implements Templates{
30+
public class DurationTemplates implements Templates {
3131
private final MethodMatcher parse = new MethodMatcher(JODA_DURATION + " parse(String)");
3232
private final MethodMatcher standardDays = new MethodMatcher(JODA_DURATION + " standardDays(long)");
3333
private final MethodMatcher standardHours = new MethodMatcher(JODA_DURATION + " standardHours(long)");

src/main/java/org/openrewrite/java/migrate/joda/templates/TimeClassMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private static JavaType.Class javaTypeClass(String fqn, JavaType.Class superType
4949
null, null, null, null, null);
5050
}
5151

52-
public static JavaType.@Nullable Class getJavaTimeType(String typeFqn) {
52+
public static JavaType.@Nullable Class getJavaTimeType(String typeFqn) {
5353
return new TimeClassMap().jodaToJavaTimeMap.get(typeFqn);
5454
}
5555

src/main/java/org/openrewrite/java/migrate/joda/templates/VarTemplates.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static JavaTemplate getTemplate(J.Assignment assignment) {
7070
JavaType.Class varType = (JavaType.Class) assignment.getVariable().getType();
7171
String typeName = JodaToJavaTimeType.get(type.getFullyQualifiedName());
7272
String varTypeName = JodaToJavaTimeType.get(varType.getFullyQualifiedName());
73-
String template = "#{any(" + varTypeName + ")} = #{any(" + typeName +")}";
73+
String template = "#{any(" + varTypeName + ")} = #{any(" + typeName + ")}";
7474
return JavaTemplate.builder(template)
7575
.build();
7676
}

0 commit comments

Comments
 (0)