Skip to content

Commit

Permalink
refactor: add @nullable to methods who may return null
Browse files Browse the repository at this point in the history
Use this link to re-run the recipe: https://app.moderne.io/builder/ji8mLIdUI?organizationId=T3BlblJld3JpdGU%3D

Co-authored-by: Moderne <team@moderne.io>
  • Loading branch information
nielsdebruin and TeamModerne committed Oct 28, 2024
1 parent ec8663c commit b82b7f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.openrewrite.java.migrate.joda.templates;

import org.jspecify.annotations.Nullable;
import org.openrewrite.java.tree.JavaType;

import java.util.HashMap;
Expand Down Expand Up @@ -48,11 +49,11 @@ private static JavaType.Class javaTypeClass(String fqn, JavaType.Class superType
null, null, null, null, null);
}

public static JavaType.Class getJavaTimeType(String typeFqn) {
public static JavaType.@Nullable Class getJavaTimeType(String typeFqn) {
return new TimeClassMap().jodaToJavaTimeMap.get(typeFqn);
}

public static String getJavaTimeShortName(String typeFqn) {
public static @Nullable String getJavaTimeShortName(String typeFqn) {
return new TimeClassMap().jodaToJavaTimeShortName.get(typeFqn);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Preconditions;
import org.openrewrite.Recipe;
Expand Down Expand Up @@ -62,8 +63,9 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
new UsesType<>(JAVA_UTIL_ZIP_INFLATER, false),
new UsesType<>(JAVA_UTIL_ZIP_ZIP_FILE, false))),
new JavaVisitor<ExecutionContext>() {

@Override
public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
public @Nullable J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
J.MethodInvocation mi = (J.MethodInvocation) super.visitMethodInvocation(method, ctx);

if (METHOD_MATCHER.matches(mi)) {
Expand Down

0 comments on commit b82b7f9

Please sign in to comment.