@@ -100,8 +100,8 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
100100 J .ClassDeclaration c = super .visitClassDeclaration (classDecl , ctx );
101101
102102 if (c .getKind () != J .ClassDeclaration .Kind .Type .Interface &&
103- c .getModifiers (). stream (). anyMatch ( mod -> mod . getType () == J .Modifier .Type .Public ) &&
104- c . getModifiers (). stream (). noneMatch ( mod -> mod . getType () == J .Modifier .Type .Abstract ) &&
103+ c .hasModifier ( J .Modifier .Type .Public ) &&
104+ ! c . hasModifier ( J .Modifier .Type .Abstract ) &&
105105 !acc .extendedClasses .contains (String .valueOf (c .getType ()))) {
106106 boolean hasTestMethods = c .getBody ().getStatements ().stream ()
107107 .filter (org .openrewrite .java .tree .J .MethodDeclaration .class ::isInstance )
@@ -111,13 +111,13 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
111111 boolean hasPublicNonTestMethods = c .getBody ().getStatements ().stream ()
112112 .filter (org .openrewrite .java .tree .J .MethodDeclaration .class ::isInstance )
113113 .map (J .MethodDeclaration .class ::cast )
114- .filter (m -> m .getModifiers (). stream (). anyMatch ( mod -> mod . getType () == J .Modifier .Type .Public ))
114+ .filter (m -> m .hasModifier ( J .Modifier .Type .Public ))
115115 .anyMatch (method -> !hasJUnit5MethodAnnotation (method ));
116116
117117 boolean hasPublicVariableDeclarations = c .getBody ().getStatements ().stream ()
118118 .filter (org .openrewrite .java .tree .J .VariableDeclarations .class ::isInstance )
119119 .map (J .VariableDeclarations .class ::cast )
120- .anyMatch (m -> m .getModifiers (). stream (). anyMatch ( mod -> mod . getType () == J .Modifier .Type .Public ));
120+ .anyMatch (m -> m .hasModifier ( J .Modifier .Type .Public ));
121121
122122 if (hasTestMethods && !hasPublicNonTestMethods && !hasPublicVariableDeclarations ) {
123123 // Remove public modifier and move associated comment
0 commit comments