13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
- package org .springframework .sbm .boot .upgrade_27_30 . helperrecipe ;
16
+ package org .springframework .sbm .boot .upgrade_27_30 ;
17
17
18
+ import org .jetbrains .annotations .NotNull ;
18
19
import org .openrewrite .Tree ;
19
20
import org .openrewrite .internal .ListUtils ;
20
21
import org .openrewrite .internal .lang .Nullable ;
@@ -38,19 +39,18 @@ public ImplementTypedInterface(J.ClassDeclaration scope, JavaType.FullyQualified
38
39
}
39
40
40
41
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 );
42
43
}
43
44
44
- public J .ClassDeclaration visitClassDeclaration (J .ClassDeclaration classDecl , P p ) {
45
+ @ NotNull
46
+ public J .ClassDeclaration visitClassDeclaration (@ NotNull J .ClassDeclaration classDecl , @ NotNull P p ) {
45
47
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 )))) {
49
49
if (!classDecl .getSimpleName ().equals (this .interfaceType .getClassName ())) {
50
50
this .maybeAddImport (this .interfaceType );
51
51
}
52
52
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 (" " ));
54
54
if (typeParameters != null && !typeParameters .isEmpty () && typeParameters .stream ().noneMatch (tp -> tp instanceof JavaType .GenericTypeVariable )) {
55
55
type = new J .ParameterizedType (UUID .randomUUID (), Space .EMPTY , Markers .EMPTY , type , buildTypeParameters (typeParameters ));
56
56
}
@@ -89,9 +89,7 @@ private JContainer<Expression> buildTypeParameters(List<JavaType> typeParameters
89
89
private TypeTree buildTypeTree (@ Nullable JavaType type , Space space ) {
90
90
if (type == null || type instanceof JavaType .Unknown ) {
91
91
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 ) {
95
93
96
94
J .Identifier identifier = new J .Identifier (Tree .randomId (),
97
95
space ,
@@ -120,9 +118,7 @@ private TypeTree buildTypeTree(@Nullable JavaType type, Space space) {
120
118
maybeAddImport (fq );
121
119
return identifier ;
122
120
}
123
- } else if (type instanceof JavaType .GenericTypeVariable ) {
124
- JavaType .GenericTypeVariable genericType = (JavaType .GenericTypeVariable ) type ;
125
-
121
+ } else if (type instanceof JavaType .GenericTypeVariable genericType ) {
126
122
if (!genericType .getName ().equals ("?" )) {
127
123
return new J .Identifier (Tree .randomId (),
128
124
space ,
0 commit comments