Skip to content

Commit 88cf8f5

Browse files
refactor: add @nullable to methods who may return null (#593)
Use this link to re-run the recipe: https://app.moderne.io/builder/ji8mLIdUI?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne <[email protected]>
1 parent ec8663c commit 88cf8f5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.openrewrite.java.migrate.joda.templates;
1717

18+
import org.jspecify.annotations.Nullable;
1819
import org.openrewrite.java.tree.JavaType;
1920

2021
import java.util.HashMap;
@@ -48,11 +49,11 @@ private static JavaType.Class javaTypeClass(String fqn, JavaType.Class superType
4849
null, null, null, null, null);
4950
}
5051

51-
public static JavaType.Class getJavaTimeType(String typeFqn) {
52+
public static JavaType.@Nullable Class getJavaTimeType(String typeFqn) {
5253
return new TimeClassMap().jodaToJavaTimeMap.get(typeFqn);
5354
}
5455

55-
public static String getJavaTimeShortName(String typeFqn) {
56+
public static @Nullable String getJavaTimeShortName(String typeFqn) {
5657
return new TimeClassMap().jodaToJavaTimeShortName.get(typeFqn);
5758
}
5859
}

src/main/java/org/openrewrite/java/migrate/util/RemoveFinalizerFromZip.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import lombok.EqualsAndHashCode;
2020
import lombok.Value;
21+
import org.jspecify.annotations.Nullable;
2122
import org.openrewrite.ExecutionContext;
2223
import org.openrewrite.Preconditions;
2324
import org.openrewrite.Recipe;
@@ -62,8 +63,9 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
6263
new UsesType<>(JAVA_UTIL_ZIP_INFLATER, false),
6364
new UsesType<>(JAVA_UTIL_ZIP_ZIP_FILE, false))),
6465
new JavaVisitor<ExecutionContext>() {
66+
6567
@Override
66-
public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
68+
public @Nullable J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
6769
J.MethodInvocation mi = (J.MethodInvocation) super.visitMethodInvocation(method, ctx);
6870

6971
if (METHOD_MATCHER.matches(mi)) {

0 commit comments

Comments
 (0)