Skip to content

Commit 9579aba

Browse files
committed
remove-package
1 parent 6bce7ae commit 9579aba

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/CrudRepositoryExtension.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
import org.jetbrains.annotations.NotNull;
2020
import org.openrewrite.*;
21+
import org.openrewrite.internal.lang.NonNullApi;
2122
import org.openrewrite.internal.lang.Nullable;
2223
import org.openrewrite.java.JavaIsoVisitor;
2324
import org.openrewrite.java.tree.J;
2425
import org.openrewrite.java.tree.JavaType;
25-
import org.springframework.sbm.boot.upgrade_27_30.helperrecipe.ImplementTypedInterface;
2626

2727
import java.util.List;
2828
import java.util.Optional;
@@ -32,6 +32,7 @@ public class CrudRepositoryExtension extends Recipe {
3232
public static final String CRUD_REPOSITORY = "org.springframework.data.repository.CrudRepository";
3333

3434
@Override
35+
@NotNull
3536
public String getDisplayName() {
3637
return "Extends CrudRepository for Interfaces that extends PagingAndSortingRepository";
3738
}
@@ -40,7 +41,8 @@ public String getDisplayName() {
4041
protected @Nullable TreeVisitor<?, ExecutionContext> getApplicableTest() {
4142
return new JavaIsoVisitor<>() {
4243
@Override
43-
public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext executionContext) {
44+
@NotNull
45+
public J.ClassDeclaration visitClassDeclaration(@NotNull J.ClassDeclaration classDecl, @NotNull ExecutionContext executionContext) {
4446
return doesItExtendPagingAndSorting(classDecl) ? applyThisRecipe(classDecl) : ceaseVisit(classDecl);
4547
}
4648

@@ -64,10 +66,12 @@ private J.ClassDeclaration applyThisRecipe(J.ClassDeclaration classDecl) {
6466
}
6567

6668
@Override
69+
@NotNull
6770
protected JavaIsoVisitor<ExecutionContext> getVisitor() {
6871
return new JavaIsoVisitor<>() {
6972
@Override
70-
public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext executionContext) {
73+
@NotNull
74+
public J.ClassDeclaration visitClassDeclaration(@NotNull J.ClassDeclaration classDecl, @NotNull ExecutionContext executionContext) {
7175

7276
Optional<JavaType.FullyQualified> pagingInterface = getExtendPagingAndSorting(classDecl);
7377
if (pagingInterface.isEmpty()) {
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.sbm.boot.upgrade_27_30.helperrecipe;
16+
package org.springframework.sbm.boot.upgrade_27_30;
1717

18+
import org.jetbrains.annotations.NotNull;
1819
import org.openrewrite.Tree;
1920
import org.openrewrite.internal.ListUtils;
2021
import org.openrewrite.internal.lang.Nullable;
@@ -38,19 +39,18 @@ public ImplementTypedInterface(J.ClassDeclaration scope, JavaType.FullyQualified
3839
}
3940

4041
public ImplementTypedInterface(J.ClassDeclaration scope, String interfaze, List<JavaType> typeParameters) {
41-
this(scope, (JavaType.FullyQualified) JavaType.ShallowClass.build(interfaze), typeParameters);
42+
this(scope, JavaType.ShallowClass.build(interfaze), typeParameters);
4243
}
4344

44-
public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, P p) {
45+
@NotNull
46+
public J.ClassDeclaration visitClassDeclaration(@NotNull J.ClassDeclaration classDecl, @NotNull P p) {
4547
J.ClassDeclaration c = super.visitClassDeclaration(classDecl, p);
46-
if (c.isScope(this.scope) && (c.getImplements() == null || c.getImplements().stream().noneMatch((f) -> {
47-
return TypeUtils.isAssignableTo(f.getType(), this.interfaceType);
48-
}))) {
48+
if (c.isScope(this.scope) && (c.getImplements() == null || c.getImplements().stream().noneMatch((f) -> TypeUtils.isAssignableTo(f.getType(), this.interfaceType)))) {
4949
if (!classDecl.getSimpleName().equals(this.interfaceType.getClassName())) {
5050
this.maybeAddImport(this.interfaceType);
5151
}
5252

53-
TypeTree type = (TypeTree) TypeTree.build(classDecl.getSimpleName().equals(this.interfaceType.getClassName()) ? this.interfaceType.getFullyQualifiedName() : this.interfaceType.getClassName()).withType(this.interfaceType).withPrefix(Space.format(" "));
53+
TypeTree type = TypeTree.build(classDecl.getSimpleName().equals(this.interfaceType.getClassName()) ? this.interfaceType.getFullyQualifiedName() : this.interfaceType.getClassName()).withType(this.interfaceType).withPrefix(Space.format(" "));
5454
if (typeParameters != null && !typeParameters.isEmpty() && typeParameters.stream().noneMatch(tp -> tp instanceof JavaType.GenericTypeVariable)) {
5555
type = new J.ParameterizedType(UUID.randomUUID(), Space.EMPTY, Markers.EMPTY, type, buildTypeParameters(typeParameters));
5656
}
@@ -89,9 +89,7 @@ private JContainer<Expression> buildTypeParameters(List<JavaType> typeParameters
8989
private TypeTree buildTypeTree(@Nullable JavaType type, Space space) {
9090
if (type == null || type instanceof JavaType.Unknown) {
9191
return null;
92-
} else if (type instanceof JavaType.FullyQualified) {
93-
94-
JavaType.FullyQualified fq = (JavaType.FullyQualified) type;
92+
} else if (type instanceof JavaType.FullyQualified fq) {
9593

9694
J.Identifier identifier = new J.Identifier(Tree.randomId(),
9795
space,
@@ -120,9 +118,7 @@ private TypeTree buildTypeTree(@Nullable JavaType type, Space space) {
120118
maybeAddImport(fq);
121119
return identifier;
122120
}
123-
} else if (type instanceof JavaType.GenericTypeVariable) {
124-
JavaType.GenericTypeVariable genericType = (JavaType.GenericTypeVariable) type;
125-
121+
} else if (type instanceof JavaType.GenericTypeVariable genericType) {
126122
if (!genericType.getName().equals("?")) {
127123
return new J.Identifier(Tree.randomId(),
128124
space,

0 commit comments

Comments
 (0)