From 0064c534273d9fb877f7e570f7a430060c88a5fb Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Thu, 10 Sep 2020 10:20:12 +0200 Subject: Add record support --- .../after-delombok/BuilderSimpleOnRecord.java | 43 +++++++ .../after-delombok/BuilderSingularOnRecord.java | 136 +++++++++++++++++++++ .../after-delombok/ConstructorsOnRecord.java | 2 + .../resource/after-delombok/DataOnRecord.java | 2 + .../after-delombok/EqualsAndHashCodeOnRecord.java | 2 + .../after-delombok/FieldDefaultsOnRecord.java | 2 + .../after-delombok/FieldNameConstantsOnRecord.java | 9 ++ .../resource/after-delombok/GetterOnRecord.java | 2 + .../after-delombok/LoggerConfigOnRecord.java | 2 + .../LoggerSlf4jNonStaticOnRecord.java | 3 + .../after-delombok/LoggerSlf4jOnRecord.java | 3 + .../NonNullExistingConstructorOnRecord.java | 22 ++++ .../resource/after-delombok/NonNullOnRecord.java | 22 ++++ .../resource/after-delombok/SetterOnRecord.java | 2 + .../after-delombok/SynchronizedInRecord.java | 6 + .../resource/after-delombok/ToStringOnRecord.java | 2 + .../after-delombok/UtilityClassOnRecord.java | 2 + .../resource/after-delombok/ValueOnRecord.java | 2 + .../resource/after-delombok/WithByOnRecord.java | 6 + .../resource/after-delombok/WithOnRecord.java | 11 ++ 20 files changed, 281 insertions(+) create mode 100644 test/transform/resource/after-delombok/BuilderSimpleOnRecord.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularOnRecord.java create mode 100644 test/transform/resource/after-delombok/ConstructorsOnRecord.java create mode 100644 test/transform/resource/after-delombok/DataOnRecord.java create mode 100644 test/transform/resource/after-delombok/EqualsAndHashCodeOnRecord.java create mode 100644 test/transform/resource/after-delombok/FieldDefaultsOnRecord.java create mode 100644 test/transform/resource/after-delombok/FieldNameConstantsOnRecord.java create mode 100644 test/transform/resource/after-delombok/GetterOnRecord.java create mode 100644 test/transform/resource/after-delombok/LoggerConfigOnRecord.java create mode 100644 test/transform/resource/after-delombok/LoggerSlf4jNonStaticOnRecord.java create mode 100644 test/transform/resource/after-delombok/LoggerSlf4jOnRecord.java create mode 100644 test/transform/resource/after-delombok/NonNullExistingConstructorOnRecord.java create mode 100644 test/transform/resource/after-delombok/NonNullOnRecord.java create mode 100644 test/transform/resource/after-delombok/SetterOnRecord.java create mode 100644 test/transform/resource/after-delombok/SynchronizedInRecord.java create mode 100644 test/transform/resource/after-delombok/ToStringOnRecord.java create mode 100644 test/transform/resource/after-delombok/UtilityClassOnRecord.java create mode 100644 test/transform/resource/after-delombok/ValueOnRecord.java create mode 100644 test/transform/resource/after-delombok/WithByOnRecord.java create mode 100644 test/transform/resource/after-delombok/WithOnRecord.java (limited to 'test/transform/resource/after-delombok') diff --git a/test/transform/resource/after-delombok/BuilderSimpleOnRecord.java b/test/transform/resource/after-delombok/BuilderSimpleOnRecord.java new file mode 100644 index 00000000..03aca3aa --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSimpleOnRecord.java @@ -0,0 +1,43 @@ +import java.util.List; + +record BuilderSimpleOnRecord(List l, String a) { + @java.lang.SuppressWarnings("all") + protected static class BuilderSimpleOnRecordBuilder { + @java.lang.SuppressWarnings("all") + private List l; + @java.lang.SuppressWarnings("all") + private String a; + + @java.lang.SuppressWarnings("all") + BuilderSimpleOnRecordBuilder() { + } + + @java.lang.SuppressWarnings("all") + public BuilderSimpleOnRecord.BuilderSimpleOnRecordBuilder l(final List l) { + this.l = l; + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSimpleOnRecord.BuilderSimpleOnRecordBuilder a(final String a) { + this.a = a; + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSimpleOnRecord build() { + return new BuilderSimpleOnRecord(this.l, this.a); + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSimpleOnRecord.BuilderSimpleOnRecordBuilder(l=" + this.l + ", a=" + this.a + ")"; + } + } + + @java.lang.SuppressWarnings("all") + protected static BuilderSimpleOnRecord.BuilderSimpleOnRecordBuilder builder() { + return new BuilderSimpleOnRecord.BuilderSimpleOnRecordBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularOnRecord.java b/test/transform/resource/after-delombok/BuilderSingularOnRecord.java new file mode 100644 index 00000000..32b37865 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularOnRecord.java @@ -0,0 +1,136 @@ +import java.util.Collection; +import java.util.List; + +record BuilderSingularOnRecord(List children, Collection scarves, @SuppressWarnings("all") List rawList) { + @java.lang.SuppressWarnings("all") + public static class BuilderSingularOnRecordBuilder { + @java.lang.SuppressWarnings("all") + private java.util.ArrayList children; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList scarves; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList rawList; + + @java.lang.SuppressWarnings("all") + BuilderSingularOnRecordBuilder() { + } + + @java.lang.SuppressWarnings("all") + public BuilderSingularOnRecord.BuilderSingularOnRecordBuilder child(final T child) { + if (this.children == null) this.children = new java.util.ArrayList(); + this.children.add(child); + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSingularOnRecord.BuilderSingularOnRecordBuilder children(final java.util.Collection children) { + if (children == null) { + throw new java.lang.NullPointerException("children cannot be null"); + } + if (this.children == null) this.children = new java.util.ArrayList(); + this.children.addAll(children); + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSingularOnRecord.BuilderSingularOnRecordBuilder clearChildren() { + if (this.children != null) this.children.clear(); + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSingularOnRecord.BuilderSingularOnRecordBuilder scarf(final Number scarf) { + if (this.scarves == null) this.scarves = new java.util.ArrayList(); + this.scarves.add(scarf); + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSingularOnRecord.BuilderSingularOnRecordBuilder scarves(final java.util.Collection scarves) { + if (scarves == null) { + throw new java.lang.NullPointerException("scarves cannot be null"); + } + if (this.scarves == null) this.scarves = new java.util.ArrayList(); + this.scarves.addAll(scarves); + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSingularOnRecord.BuilderSingularOnRecordBuilder clearScarves() { + if (this.scarves != null) this.scarves.clear(); + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSingularOnRecord.BuilderSingularOnRecordBuilder rawList(final java.lang.Object rawList) { + if (this.rawList == null) this.rawList = new java.util.ArrayList(); + this.rawList.add(rawList); + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSingularOnRecord.BuilderSingularOnRecordBuilder rawList(final java.util.Collection rawList) { + if (rawList == null) { + throw new java.lang.NullPointerException("rawList cannot be null"); + } + if (this.rawList == null) this.rawList = new java.util.ArrayList(); + this.rawList.addAll(rawList); + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSingularOnRecord.BuilderSingularOnRecordBuilder clearRawList() { + if (this.rawList != null) this.rawList.clear(); + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderSingularOnRecord build() { + java.util.List children; + switch (this.children == null ? 0 : this.children.size()) { + case 0: + children = java.util.Collections.emptyList(); + break; + case 1: + children = java.util.Collections.singletonList(this.children.get(0)); + break; + default: + children = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.children)); + } + java.util.Collection scarves; + switch (this.scarves == null ? 0 : this.scarves.size()) { + case 0: + scarves = java.util.Collections.emptyList(); + break; + case 1: + scarves = java.util.Collections.singletonList(this.scarves.get(0)); + break; + default: + scarves = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.scarves)); + } + java.util.List rawList; + switch (this.rawList == null ? 0 : this.rawList.size()) { + case 0: + rawList = java.util.Collections.emptyList(); + break; + case 1: + rawList = java.util.Collections.singletonList(this.rawList.get(0)); + break; + default: + rawList = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.rawList)); + } + return new BuilderSingularOnRecord(children, scarves, rawList); + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularOnRecord.BuilderSingularOnRecordBuilder(children=" + this.children + ", scarves=" + this.scarves + ", rawList=" + this.rawList + ")"; + } + } + + @java.lang.SuppressWarnings("all") + public static BuilderSingularOnRecord.BuilderSingularOnRecordBuilder builder() { + return new BuilderSingularOnRecord.BuilderSingularOnRecordBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/ConstructorsOnRecord.java b/test/transform/resource/after-delombok/ConstructorsOnRecord.java new file mode 100644 index 00000000..8cef8809 --- /dev/null +++ b/test/transform/resource/after-delombok/ConstructorsOnRecord.java @@ -0,0 +1,2 @@ +record ConstructorsOnRecord(String a, String b) { +} diff --git a/test/transform/resource/after-delombok/DataOnRecord.java b/test/transform/resource/after-delombok/DataOnRecord.java new file mode 100644 index 00000000..b4384dce --- /dev/null +++ b/test/transform/resource/after-delombok/DataOnRecord.java @@ -0,0 +1,2 @@ +record DataOnRecord(String a, String b) { +} diff --git a/test/transform/resource/after-delombok/EqualsAndHashCodeOnRecord.java b/test/transform/resource/after-delombok/EqualsAndHashCodeOnRecord.java new file mode 100644 index 00000000..949cdec6 --- /dev/null +++ b/test/transform/resource/after-delombok/EqualsAndHashCodeOnRecord.java @@ -0,0 +1,2 @@ +record EqualsAndHashCodeOnRecord(String a, String b) { +} diff --git a/test/transform/resource/after-delombok/FieldDefaultsOnRecord.java b/test/transform/resource/after-delombok/FieldDefaultsOnRecord.java new file mode 100644 index 00000000..1287dcb0 --- /dev/null +++ b/test/transform/resource/after-delombok/FieldDefaultsOnRecord.java @@ -0,0 +1,2 @@ +record FieldDefaultsOnRecord(String a, String b) { +} diff --git a/test/transform/resource/after-delombok/FieldNameConstantsOnRecord.java b/test/transform/resource/after-delombok/FieldNameConstantsOnRecord.java new file mode 100644 index 00000000..2e3339fa --- /dev/null +++ b/test/transform/resource/after-delombok/FieldNameConstantsOnRecord.java @@ -0,0 +1,9 @@ +record FieldNameConstantsOnRecord(String iAmADvdPlayer, int $skipMe, int andMe, String butPrintMePlease) { + static double skipMeToo; + + @java.lang.SuppressWarnings("all") + static final class Fields { + public static final java.lang.String iAmADvdPlayer = "iAmADvdPlayer"; + public static final java.lang.String butPrintMePlease = "butPrintMePlease"; + } +} diff --git a/test/transform/resource/after-delombok/GetterOnRecord.java b/test/transform/resource/after-delombok/GetterOnRecord.java new file mode 100644 index 00000000..5090e92d --- /dev/null +++ b/test/transform/resource/after-delombok/GetterOnRecord.java @@ -0,0 +1,2 @@ +record GetterOnRecord(String a, String b) { +} diff --git a/test/transform/resource/after-delombok/LoggerConfigOnRecord.java b/test/transform/resource/after-delombok/LoggerConfigOnRecord.java new file mode 100644 index 00000000..5b43f24e --- /dev/null +++ b/test/transform/resource/after-delombok/LoggerConfigOnRecord.java @@ -0,0 +1,2 @@ +record LoggerConfigOnRecord(String a, String b) { +} diff --git a/test/transform/resource/after-delombok/LoggerSlf4jNonStaticOnRecord.java b/test/transform/resource/after-delombok/LoggerSlf4jNonStaticOnRecord.java new file mode 100644 index 00000000..e59ed6d3 --- /dev/null +++ b/test/transform/resource/after-delombok/LoggerSlf4jNonStaticOnRecord.java @@ -0,0 +1,3 @@ +record LoggerSlf4jOnRecord(String a, String b) { + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jOnRecord.class); +} diff --git a/test/transform/resource/after-delombok/LoggerSlf4jOnRecord.java b/test/transform/resource/after-delombok/LoggerSlf4jOnRecord.java new file mode 100644 index 00000000..e59ed6d3 --- /dev/null +++ b/test/transform/resource/after-delombok/LoggerSlf4jOnRecord.java @@ -0,0 +1,3 @@ +record LoggerSlf4jOnRecord(String a, String b) { + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jOnRecord.class); +} diff --git a/test/transform/resource/after-delombok/NonNullExistingConstructorOnRecord.java b/test/transform/resource/after-delombok/NonNullExistingConstructorOnRecord.java new file mode 100644 index 00000000..de2757ee --- /dev/null +++ b/test/transform/resource/after-delombok/NonNullExistingConstructorOnRecord.java @@ -0,0 +1,22 @@ +import lombok.NonNull; + +record NonNullOnRecord(@NonNull String a, @NonNull String b) { + public NonNullOnRecord(@NonNull String b) { + this("default", b); + if (b == null) { + throw new java.lang.NullPointerException("b is marked non-null but is null"); + } + } + + @java.lang.SuppressWarnings("all") + public NonNullOnRecord(@NonNull final String a, @NonNull final String b) { + if (a == null) { + throw new java.lang.NullPointerException("a is marked non-null but is null"); + } + if (b == null) { + throw new java.lang.NullPointerException("b is marked non-null but is null"); + } + this.a = a; + this.b = b; + } +} diff --git a/test/transform/resource/after-delombok/NonNullOnRecord.java b/test/transform/resource/after-delombok/NonNullOnRecord.java new file mode 100644 index 00000000..7147f49c --- /dev/null +++ b/test/transform/resource/after-delombok/NonNullOnRecord.java @@ -0,0 +1,22 @@ +import lombok.NonNull; + +record NonNullOnRecord(@NonNull String a, @NonNull String b) { + public void method(@NonNull String param) { + if (param == null) { + throw new java.lang.NullPointerException("param is marked non-null but is null"); + } + String asd = "a"; + } + + @java.lang.SuppressWarnings("all") + public NonNullOnRecord(@NonNull final String a, @NonNull final String b) { + if (a == null) { + throw new java.lang.NullPointerException("a is marked non-null but is null"); + } + if (b == null) { + throw new java.lang.NullPointerException("b is marked non-null but is null"); + } + this.a = a; + this.b = b; + } +} diff --git a/test/transform/resource/after-delombok/SetterOnRecord.java b/test/transform/resource/after-delombok/SetterOnRecord.java new file mode 100644 index 00000000..39a911ca --- /dev/null +++ b/test/transform/resource/after-delombok/SetterOnRecord.java @@ -0,0 +1,2 @@ +record SetterOnRecord(String a, String b) { +} diff --git a/test/transform/resource/after-delombok/SynchronizedInRecord.java b/test/transform/resource/after-delombok/SynchronizedInRecord.java new file mode 100644 index 00000000..67ca868a --- /dev/null +++ b/test/transform/resource/after-delombok/SynchronizedInRecord.java @@ -0,0 +1,6 @@ +// version 14: +record SynchronizedInRecord(String a, String b) { + public void foo() { + String foo = "bar"; + } +} diff --git a/test/transform/resource/after-delombok/ToStringOnRecord.java b/test/transform/resource/after-delombok/ToStringOnRecord.java new file mode 100644 index 00000000..84db33be --- /dev/null +++ b/test/transform/resource/after-delombok/ToStringOnRecord.java @@ -0,0 +1,2 @@ +record ToStringOnRecord(String a, String b) { +} diff --git a/test/transform/resource/after-delombok/UtilityClassOnRecord.java b/test/transform/resource/after-delombok/UtilityClassOnRecord.java new file mode 100644 index 00000000..fbe27370 --- /dev/null +++ b/test/transform/resource/after-delombok/UtilityClassOnRecord.java @@ -0,0 +1,2 @@ +record UtilityClassOnRecord(String a, String b) { +} diff --git a/test/transform/resource/after-delombok/ValueOnRecord.java b/test/transform/resource/after-delombok/ValueOnRecord.java new file mode 100644 index 00000000..d3d0e6db --- /dev/null +++ b/test/transform/resource/after-delombok/ValueOnRecord.java @@ -0,0 +1,2 @@ +record ValueOnRecord(String a, String b) { +} diff --git a/test/transform/resource/after-delombok/WithByOnRecord.java b/test/transform/resource/after-delombok/WithByOnRecord.java new file mode 100644 index 00000000..43a4c8c3 --- /dev/null +++ b/test/transform/resource/after-delombok/WithByOnRecord.java @@ -0,0 +1,6 @@ +record WithByOnRecord(String a, String b) { + @java.lang.SuppressWarnings("all") + public WithByOnRecord withABy(final java.util.function.Function transformer) { + return new WithByOnRecord(transformer.apply(this.a), this.b); + } +} diff --git a/test/transform/resource/after-delombok/WithOnRecord.java b/test/transform/resource/after-delombok/WithOnRecord.java new file mode 100644 index 00000000..bfb123bc --- /dev/null +++ b/test/transform/resource/after-delombok/WithOnRecord.java @@ -0,0 +1,11 @@ +record WithOnRecord(String a, String b) { + @java.lang.SuppressWarnings("all") + public WithOnRecord withA(final String a) { + return this.a == a ? this : new WithOnRecord(a, this.b); + } + + @java.lang.SuppressWarnings("all") + public WithOnRecord withB(final String b) { + return this.b == b ? this : new WithOnRecord(this.a, b); + } +} -- cgit From fa0b5249cf5fee28d9be13ecdf0225f651f686aa Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Sat, 12 Sep 2020 14:35:40 +0200 Subject: Support With(By) on records and record components This also replaces the javac/eclipse specific code for searching the parent fields of an annotation by a search based on the lombok AST. --- src/core/lombok/core/LombokNode.java | 10 ++++------ src/core/lombok/eclipse/EclipseNode.java | 10 ---------- src/core/lombok/eclipse/handlers/HandleWithBy.java | 7 +------ src/core/lombok/javac/JavacNode.java | 10 ---------- test/transform/resource/after-delombok/WithByOnRecord.java | 5 +++++ .../resource/after-delombok/WithByOnRecordComponent.java | 6 ++++++ .../resource/after-delombok/WithOnRecordComponent.java | 6 ++++++ test/transform/resource/after-ecj/WithByOnRecord.java | 7 +++++-- .../resource/after-ecj/WithByOnRecordComponent.java | 13 +++++++++++++ .../transform/resource/after-ecj/WithOnRecordComponent.java | 13 +++++++++++++ test/transform/resource/before/WithByOnRecord.java | 3 ++- test/transform/resource/before/WithByOnRecordComponent.java | 6 ++++++ test/transform/resource/before/WithOnRecordComponent.java | 6 ++++++ 13 files changed, 67 insertions(+), 35 deletions(-) create mode 100644 test/transform/resource/after-delombok/WithByOnRecordComponent.java create mode 100644 test/transform/resource/after-delombok/WithOnRecordComponent.java create mode 100644 test/transform/resource/after-ecj/WithByOnRecordComponent.java create mode 100644 test/transform/resource/after-ecj/WithOnRecordComponent.java create mode 100644 test/transform/resource/before/WithByOnRecordComponent.java create mode 100644 test/transform/resource/before/WithOnRecordComponent.java (limited to 'test/transform/resource/after-delombok') diff --git a/src/core/lombok/core/LombokNode.java b/src/core/lombok/core/LombokNode.java index abfc66a6..34273a86 100644 --- a/src/core/lombok/core/LombokNode.java +++ b/src/core/lombok/core/LombokNode.java @@ -160,17 +160,15 @@ public abstract class LombokNode, L extends LombokNode fields = new ArrayList(); for (L potentialField : type.down()) { if (potentialField.getKind() != Kind.FIELD) continue; - if (fieldContainsAnnotation(potentialField.get(), get())) fields.add(potentialField); + for (L child : potentialField.down()) { + if (child.getKind() != Kind.ANNOTATION) continue; + if (child.get() == get()) fields.add(potentialField); + } } return fields; } - /** - * Return {@code true} if the annotation is attached to the field. - */ - protected abstract boolean fieldContainsAnnotation(N field, N annotation); - /** * Returns the direct parent node in the AST tree of this node. For example, a local variable declaration's * direct parent can be e.g. an If block, but its {@code up()} {@code LombokNode} is the {@code Method} that contains it. diff --git a/src/core/lombok/eclipse/EclipseNode.java b/src/core/lombok/eclipse/EclipseNode.java index 12e9ccdb..361a8d42 100644 --- a/src/core/lombok/eclipse/EclipseNode.java +++ b/src/core/lombok/eclipse/EclipseNode.java @@ -143,16 +143,6 @@ public class EclipseNode extends lombok.core.LombokNode { switch (node.getKind()) { case FIELD: - Set fields = new LinkedHashSet(); - fields.add(node); - fields.addAll(annotationNode.upFromAnnotationToFields()); - createWithByForFields(level, fields, annotationNode, true, onMethod); + createWithByForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod); break; case TYPE: if (!onMethod.isEmpty()) { diff --git a/src/core/lombok/javac/JavacNode.java b/src/core/lombok/javac/JavacNode.java index 3de3f38b..e648cd51 100644 --- a/src/core/lombok/javac/JavacNode.java +++ b/src/core/lombok/javac/JavacNode.java @@ -186,16 +186,6 @@ public class JavacNode extends lombok.core.LombokNode transformer) { return new WithByOnRecord(transformer.apply(this.a), this.b); } + + @java.lang.SuppressWarnings("all") + public WithByOnRecord withBBy(final java.util.function.Function transformer) { + return new WithByOnRecord(this.a, transformer.apply(this.b)); + } } diff --git a/test/transform/resource/after-delombok/WithByOnRecordComponent.java b/test/transform/resource/after-delombok/WithByOnRecordComponent.java new file mode 100644 index 00000000..5af50625 --- /dev/null +++ b/test/transform/resource/after-delombok/WithByOnRecordComponent.java @@ -0,0 +1,6 @@ +record WithByOnRecordComponent(String a, String b) { + @java.lang.SuppressWarnings("all") + public WithByOnRecordComponent withABy(final java.util.function.Function transformer) { + return new WithByOnRecordComponent(transformer.apply(this.a), this.b); + } +} diff --git a/test/transform/resource/after-delombok/WithOnRecordComponent.java b/test/transform/resource/after-delombok/WithOnRecordComponent.java new file mode 100644 index 00000000..a5f4ec36 --- /dev/null +++ b/test/transform/resource/after-delombok/WithOnRecordComponent.java @@ -0,0 +1,6 @@ +record WithOnRecordComponent(String a, String b) { + @java.lang.SuppressWarnings("all") + public WithOnRecordComponent withA(final String a) { + return this.a == a ? this : new WithOnRecordComponent(a, this.b); + } +} diff --git a/test/transform/resource/after-ecj/WithByOnRecord.java b/test/transform/resource/after-ecj/WithByOnRecord.java index 9048c9f4..c40841c8 100644 --- a/test/transform/resource/after-ecj/WithByOnRecord.java +++ b/test/transform/resource/after-ecj/WithByOnRecord.java @@ -1,8 +1,8 @@ import lombok.experimental.WithBy; -record WithByOnRecord(String a, String b) { +@WithBy record WithByOnRecord(String a, String b) { /* Implicit */ private final String a; /* Implicit */ private final String b; - public WithByOnRecord( String a, String b) { + public WithByOnRecord(String a, String b) { super(); .a = a; .b = b; @@ -10,4 +10,7 @@ record WithByOnRecord(String a, String b) { public @java.lang.SuppressWarnings("all") WithByOnRecord withABy(final java.util.function.Function transformer) { return new WithByOnRecord(transformer.apply(this.a), this.b); } + public @java.lang.SuppressWarnings("all") WithByOnRecord withBBy(final java.util.function.Function transformer) { + return new WithByOnRecord(this.a, transformer.apply(this.b)); + } } diff --git a/test/transform/resource/after-ecj/WithByOnRecordComponent.java b/test/transform/resource/after-ecj/WithByOnRecordComponent.java new file mode 100644 index 00000000..19fe508c --- /dev/null +++ b/test/transform/resource/after-ecj/WithByOnRecordComponent.java @@ -0,0 +1,13 @@ +import lombok.experimental.WithBy; +record WithByOnRecordComponent(String a, String b) { +/* Implicit */ private final String a; +/* Implicit */ private final String b; + public WithByOnRecordComponent( String a, String b) { + super(); + .a = a; + .b = b; + } + public @java.lang.SuppressWarnings("all") WithByOnRecordComponent withABy(final java.util.function.Function transformer) { + return new WithByOnRecordComponent(transformer.apply(this.a), this.b); + } +} diff --git a/test/transform/resource/after-ecj/WithOnRecordComponent.java b/test/transform/resource/after-ecj/WithOnRecordComponent.java new file mode 100644 index 00000000..42028f81 --- /dev/null +++ b/test/transform/resource/after-ecj/WithOnRecordComponent.java @@ -0,0 +1,13 @@ +import lombok.With; +record WithOnRecordComponent(String a, String b) { +/* Implicit */ private final String a; +/* Implicit */ private final String b; + public WithOnRecordComponent( String a, String b) { + super(); + .a = a; + .b = b; + } + public @java.lang.SuppressWarnings("all") WithOnRecordComponent withA(final String a) { + return ((this.a == a) ? this : new WithOnRecordComponent(a, this.b)); + } +} diff --git a/test/transform/resource/before/WithByOnRecord.java b/test/transform/resource/before/WithByOnRecord.java index 98cbff9b..6c7b8e2d 100644 --- a/test/transform/resource/before/WithByOnRecord.java +++ b/test/transform/resource/before/WithByOnRecord.java @@ -2,5 +2,6 @@ import lombok.experimental.WithBy; -record WithByOnRecord(@WithBy String a, String b) { +@WithBy +record WithByOnRecord(String a, String b) { } \ No newline at end of file diff --git a/test/transform/resource/before/WithByOnRecordComponent.java b/test/transform/resource/before/WithByOnRecordComponent.java new file mode 100644 index 00000000..7e0f0f19 --- /dev/null +++ b/test/transform/resource/before/WithByOnRecordComponent.java @@ -0,0 +1,6 @@ +// version 14: + +import lombok.experimental.WithBy; + +record WithByOnRecordComponent(@WithBy String a, String b) { +} \ No newline at end of file diff --git a/test/transform/resource/before/WithOnRecordComponent.java b/test/transform/resource/before/WithOnRecordComponent.java new file mode 100644 index 00000000..6f827851 --- /dev/null +++ b/test/transform/resource/before/WithOnRecordComponent.java @@ -0,0 +1,6 @@ +// version 14: + +import lombok.With; + +record WithOnRecordComponent(@With String a, String b) { +} \ No newline at end of file -- cgit