Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,21 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration cd, Execution
classDeclaration = new RemoveAnnotationVisitor(LOMBOK_VALUE_MATCHER).visitClassDeclaration(classDeclaration, ctx);
maybeRemoveImport("lombok.Value");

List<J.Modifier> mappedModifiers = ListUtils.map(classDeclaration.getModifiers(), modifier -> {
J.Modifier.Type type = modifier.getType();
if (type == J.Modifier.Type.Static || type == J.Modifier.Type.Final) {
return null;
}
return modifier;
});
J.ClassDeclaration.Kind kind = classDeclaration.withKind(J.ClassDeclaration.Kind.Type.Record).getPadding().getKind();
if (mappedModifiers.isEmpty()) {
kind = kind.withPrefix(kind.getPrefix().withWhitespace(""));
}

classDeclaration = classDeclaration
.withKind(J.ClassDeclaration.Kind.Type.Record)
.withModifiers(ListUtils.map(classDeclaration.getModifiers(), modifier -> {
J.Modifier.Type type = modifier.getType();
if (type == J.Modifier.Type.Static || type == J.Modifier.Type.Final) {
return null;
}
return modifier;
}))
.getPadding().withKind(kind)
.withModifiers(mappedModifiers)
.withType(buildRecordType(classDeclaration))
.withBody(classDeclaration.getBody()
.withStatements(bodyStatements)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class A {
package example;

public record A(
String test) {
String test) {
}
"""
),
Expand Down Expand Up @@ -121,9 +121,9 @@ public class Test {
""",
"""
public record Test(
String field1,
String field1,

String field2) {
String field2) {
@Override
public String toString() {
return "Test(" +
Expand Down Expand Up @@ -166,7 +166,7 @@ public class B {
import lombok.Value;

public record A(
String test) {
String test) {
}

@Value
Expand Down Expand Up @@ -201,14 +201,12 @@ static class B {

public class A {
record B(
String test) {
String test) {
}
}
"""
)
);


}

@Test
Expand All @@ -233,7 +231,7 @@ public class A implements Serializable {
import java.io.Serializable;

public record A(
String test) implements Serializable {
String test) implements Serializable {
}
"""
)
Expand Down Expand Up @@ -266,7 +264,7 @@ public class A implements Serializable {

@Builder
public record A(
String test) implements Serializable {
String test) implements Serializable {
}
"""
)
Expand All @@ -289,7 +287,7 @@ public class Foo {
""",
"""
public record Foo(
boolean bar) {
boolean bar) {
}"""
),
java(
Expand Down Expand Up @@ -329,9 +327,9 @@ public class Config {
""",
"""
public record Config(
boolean enabled,
Boolean active,
String name) {
boolean enabled,
Boolean active,
String name) {
}
"""
),
Expand Down Expand Up @@ -384,7 +382,7 @@ Supplier<String> usingMethodReference() {
import java.util.function.Supplier;

record A(
String test) {
String test) {
}

class Using {
Expand Down