Skip to content

Commit 929bfbb

Browse files
committed
Apply automated suggestions
1 parent e20e249 commit 929bfbb

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

src/main/java/org/openrewrite/java/migrate/lombok/SummarizeGetter.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2024 the original author or authors.
2+
* Copyright 2025 the original author or authors.
33
* <p>
4-
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* Licensed under the Moderne Source Available License (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
* <p>
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://docs.moderne.io/licensing/moderne-source-available-license
99
* <p>
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,6 +17,7 @@
1717

1818
import lombok.EqualsAndHashCode;
1919
import lombok.Value;
20+
import org.jspecify.annotations.Nullable;
2021
import org.openrewrite.ExecutionContext;
2122
import org.openrewrite.Recipe;
2223
import org.openrewrite.TreeVisitor;
@@ -116,13 +117,13 @@ private J.VariableDeclarations fixFormat(J.VariableDeclarations initial, J.Varia
116117
}
117118

118119
@Override
119-
public J.Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ctx) {
120-
return annotation.getSimpleName().equals("Getter")
121-
&& annotation.getArguments() == null //no Access level, or other arguments
120+
public J.@Nullable Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ctx) {
121+
return annotation.getSimpleName().equals("Getter") &&
122+
annotation.getArguments() == null && //no Access level, or other arguments
122123
//should only trigger on field annotation, not class annotation
123-
&& getCursor().getParent().getValue() instanceof J.VariableDeclarations
124-
? null // -> delete
125-
: annotation; // -> keep
124+
getCursor().getParent().getValue() instanceof J.VariableDeclarations ?
125+
null : // -> delete
126+
annotation; // -> keep
126127
}
127128
}
128129
}

src/main/java/org/openrewrite/java/migrate/lombok/SummarizeSetter.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2024 the original author or authors.
2+
* Copyright 2025 the original author or authors.
33
* <p>
4-
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* Licensed under the Moderne Source Available License (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
* <p>
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://docs.moderne.io/licensing/moderne-source-available-license
99
* <p>
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,6 +17,7 @@
1717

1818
import lombok.EqualsAndHashCode;
1919
import lombok.Value;
20+
import org.jspecify.annotations.Nullable;
2021
import org.openrewrite.ExecutionContext;
2122
import org.openrewrite.Recipe;
2223
import org.openrewrite.TreeVisitor;
@@ -120,15 +121,15 @@ private J.VariableDeclarations fixFormat(J.VariableDeclarations initial, J.Varia
120121
}
121122

122123
@Override
123-
public J.Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ctx) {
124+
public J.@Nullable Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ctx) {
124125
boolean isSetterAnnotated = annotation.getSimpleName().equals("Setter")
125126
&& annotation.getArguments() == null; //no Access level, or other arguments
126127

127-
return isSetterAnnotated
128+
return isSetterAnnotated &&
128129
//should only trigger on field annotation, not class annotation
129-
&& getCursor().getParent().getValue() instanceof J.VariableDeclarations
130-
? null // -> delete
131-
: annotation; // -> keep
130+
getCursor().getParent().getValue() instanceof J.VariableDeclarations ?
131+
null : // -> delete
132+
annotation; // -> keep
132133
}
133134
}
134135
}

src/test/java/org/openrewrite/java/migrate/lombok/SummarizeGetterTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2024 the original author or authors.
2+
* Copyright 2025 the original author or authors.
33
* <p>
4-
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* Licensed under the Moderne Source Available License (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
* <p>
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://docs.moderne.io/licensing/moderne-source-available-license
99
* <p>
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,

src/test/java/org/openrewrite/java/migrate/lombok/SummarizeSetterTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2024 the original author or authors.
2+
* Copyright 2025 the original author or authors.
33
* <p>
4-
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* Licensed under the Moderne Source Available License (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
* <p>
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* https://docs.moderne.io/licensing/moderne-source-available-license
99
* <p>
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,

0 commit comments

Comments
 (0)