Skip to content

Commit

Permalink
refactor: Move @Nullable method annotations to the return type
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider and TeamModerne committed Jul 16, 2024
1 parent 3eb8e87 commit 399931b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ public J.Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ct
return anno;
}

@Nullable
private String getLiteralAnnotationArgumentValue(J.Annotation anno) {
private @Nullable String getLiteralAnnotationArgumentValue(J.Annotation anno) {
String annotationArgumentValue = null;
if (anno.getArguments() != null && anno.getArguments().size() == 1 && anno.getArguments().get(0) instanceof J.Literal) {
J.Literal literal = (J.Literal) anno.getArguments().get(0);
Expand All @@ -147,8 +146,7 @@ private String getLiteralAnnotationArgumentValue(J.Annotation anno) {
return annotationArgumentValue;
}

@Nullable
private String getAnnotationArgumentForInitMethod(J.Annotation anno, String... variableNames) {
private @Nullable String getAnnotationArgumentForInitMethod(J.Annotation anno, String... variableNames) {
String value = null;
if (anno.getArguments() != null && anno.getArguments().size() == 1
&& anno.getArguments().get(0) instanceof J.Assignment
Expand Down Expand Up @@ -292,8 +290,7 @@ private J.Annotation maybeReplaceParametersAnnotation(Cursor anno, String method
return anno.getValue();
}

@Nullable
private String getAnnotationArgumentValueForMethodTemplate(J.Annotation anno) {
private @Nullable String getAnnotationArgumentValueForMethodTemplate(J.Annotation anno) {
String annotationArgumentValue = null;
if (anno.getArguments() != null && anno.getArguments().size() == 1) {
Expression annoArg = anno.getArguments().get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ private static boolean isFieldAlreadyDefined(J.Block classBody, String fieldName
return false;
}

@Nullable
private static J.MethodDeclaration getFirstTestMethod(List<J.MethodDeclaration> methods) {
private static @Nullable J.MethodDeclaration getFirstTestMethod(List<J.MethodDeclaration> methods) {
for (J.MethodDeclaration methodDeclaration : methods) {
for (J.Annotation annotation : methodDeclaration.getLeadingAnnotations()) {
if ("Test".equals(annotation.getSimpleName())) {
Expand Down Expand Up @@ -559,8 +558,7 @@ private J.MethodInvocation modifyWhenMethodInvocation(J.MethodInvocation whenMet
return whenMethod;
}

@Nullable
private String getDeclaringClassName(J.MethodInvocation mi) {
private @Nullable String getDeclaringClassName(J.MethodInvocation mi) {
JavaType.Method methodType = mi.getMethodType();
if (methodType != null) {
JavaType.FullyQualified declaringType = methodType.getDeclaringType();
Expand All @@ -569,8 +567,7 @@ private String getDeclaringClassName(J.MethodInvocation mi) {
return null;
}

@Nullable
private J.Identifier getFieldIdentifier(String fieldName) {
private @Nullable J.Identifier getFieldIdentifier(String fieldName) {
return getMockedTypesFields().keySet().stream()
.filter(identifier -> identifier.getSimpleName().equals(fieldName)).findFirst()
.orElseGet(() -> {
Expand Down

0 comments on commit 399931b

Please sign in to comment.