Skip to content

Commit 07673dd

Browse files
Cleanup
1 parent 2f08c60 commit 07673dd

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

spring-data-eclipse-store-migration/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@
141141
<artifactId>rewrite-test</artifactId>
142142
<scope>test</scope>
143143
</dependency>
144+
<dependency>
145+
<groupId>org.slf4j</groupId>
146+
<artifactId>slf4j-simple</artifactId>
147+
<version>2.0.11</version>
148+
<scope>test</scope>
149+
</dependency>
150+
144151
</dependencies>
145152

146153
<build>

spring-data-eclipse-store-migration/src/main/java/software/xdev/spring/data/eclipse/store/AddAnnotationToOtherAnnotation.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.openrewrite.java.JavaTemplate;
2828
import org.openrewrite.java.tree.J;
2929

30+
3031
public class AddAnnotationToOtherAnnotation extends Recipe
3132
{
3233

@@ -83,8 +84,8 @@ public String getDescription()
8384
@Override
8485
public TreeVisitor<?, ExecutionContext> getVisitor()
8586
{
86-
final AnnotationMatcher EXISTING_ANNOTATION_MATCHER = new AnnotationMatcher(this.existingAnnotationType);
87-
final AnnotationMatcher NEW_ANNOTATION_MATCHER = new AnnotationMatcher(this.annotationTypeToAdd);
87+
final AnnotationMatcher existingAnnotationMatcher = new AnnotationMatcher(this.existingAnnotationType);
88+
final AnnotationMatcher newAnnotationMatcher = new AnnotationMatcher(this.annotationTypeToAdd);
8889
return new JavaIsoVisitor<>()
8990
{
9091
@Override
@@ -95,17 +96,17 @@ public J.ClassDeclaration visitClassDeclaration(
9596
final J.ClassDeclaration cd = super.visitClassDeclaration(classDecl, executionContext);
9697

9798
if(
98-
cd.getAnnotations() == null ||
99-
cd.getLeadingAnnotations()
100-
.stream()
101-
.filter(annotation -> EXISTING_ANNOTATION_MATCHER.matches(annotation))
102-
.findAny()
103-
.isEmpty() ||
104-
cd.getLeadingAnnotations()
105-
.stream()
106-
.filter(annotation -> NEW_ANNOTATION_MATCHER.matches(annotation))
107-
.findAny()
108-
.isPresent()
99+
cd.getAnnotations() == null
100+
|| cd.getLeadingAnnotations()
101+
.stream()
102+
.filter(annotation -> existingAnnotationMatcher.matches(annotation))
103+
.findAny()
104+
.isEmpty()
105+
|| cd.getLeadingAnnotations()
106+
.stream()
107+
.filter(annotation -> newAnnotationMatcher.matches(annotation))
108+
.findAny()
109+
.isPresent()
109110
)
110111
{
111112
return cd;

spring-data-eclipse-store-migration/src/main/resources/META-INF/rewrite/rewrite.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,3 @@ recipeList:
4040
- org.openrewrite.java.RemoveAnnotation:
4141
# https://docs.openrewrite.org/reference/method-patterns
4242
annotationPattern: '@org.springframework.data.jpa.repository.Query *(..)'
43-
44-
- org.openrewrite.java.RemoveUnusedImports

0 commit comments

Comments
 (0)