File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
main/java/org/openrewrite/java/migrate/lombok
test/java/org/openrewrite/java/migrate/lombok Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1919import org .jspecify .annotations .Nullable ;
2020import org .openrewrite .Cursor ;
2121import org .openrewrite .internal .StringUtils ;
22+ import org .openrewrite .java .marker .CompactConstructor ;
2223import org .openrewrite .java .tree .Expression ;
2324import org .openrewrite .java .tree .Flag ;
2425import org .openrewrite .java .tree .J ;
@@ -38,7 +39,7 @@ static boolean isGetter(Cursor cursor) {
3839 return false ;
3940 }
4041 // Check signature: no parameters
41- if (!(method .getParameters ().get (0 ) instanceof J .Empty ) || method .getReturnTypeExpression () == null ) {
42+ if (method . getMarkers (). findFirst ( CompactConstructor . class ). isPresent () || !(method .getParameters ().get (0 ) instanceof J .Empty ) || method .getReturnTypeExpression () == null ) {
4243 return false ;
4344 }
4445 // Check body: just a return statement
Original file line number Diff line number Diff line change @@ -560,6 +560,23 @@ public int getFoo() {
560560 );
561561 }
562562
563+ @ Test
564+ void noChangeRecordWithCompactContractor () {
565+ rewriteRun (// language=java
566+ java (
567+ """
568+ public record Foo(String id) {
569+ public Foo {
570+ if (id == null || id.isBlank()) {
571+ throw new IllegalArgumentException("ID cannot be null or blank");
572+ }
573+ }
574+ }
575+ """
576+ )
577+ );
578+ }
579+
563580 @ Issue ("https://github.com/openrewrite/rewrite/issues/5015" )
564581 @ Test
565582 void addOnMethodArgIfAnnotated () {
You can’t perform that action at this time.
0 commit comments