From a991bebe41bd5037323f682301a5fe77ea89b7b9 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 27 Aug 2019 00:15:02 +0200 Subject: [issue #2368] [withBy] support for javac --- .../resource/after-delombok/WithByNullAnnos.java | 13 +++++ .../resource/after-delombok/WithByTypes.java | 62 ++++++++++++++++++++++ .../transform/resource/before/WithByNullAnnos.java | 6 +++ test/transform/resource/before/WithByTypes.java | 18 +++++++ 4 files changed, 99 insertions(+) create mode 100644 test/transform/resource/after-delombok/WithByNullAnnos.java create mode 100644 test/transform/resource/after-delombok/WithByTypes.java create mode 100644 test/transform/resource/before/WithByNullAnnos.java create mode 100644 test/transform/resource/before/WithByTypes.java (limited to 'test') diff --git a/test/transform/resource/after-delombok/WithByNullAnnos.java b/test/transform/resource/after-delombok/WithByNullAnnos.java new file mode 100644 index 00000000..cdaed973 --- /dev/null +++ b/test/transform/resource/after-delombok/WithByNullAnnos.java @@ -0,0 +1,13 @@ +import java.util.List; +public class WithByNullAnnos { + final List test; + @java.lang.SuppressWarnings("all") + public WithByNullAnnos(final List test) { + this.test = test; + } + @org.checkerframework.checker.nullness.qual.NonNull + @java.lang.SuppressWarnings("all") + public WithByNullAnnos withTestBy(final java.util.function.@org.checkerframework.checker.nullness.qual.NonNull Function, ? extends List> transformer) { + return new WithByNullAnnos(transformer.apply(this.test)); + } +} diff --git a/test/transform/resource/after-delombok/WithByTypes.java b/test/transform/resource/after-delombok/WithByTypes.java new file mode 100644 index 00000000..e5e2fb07 --- /dev/null +++ b/test/transform/resource/after-delombok/WithByTypes.java @@ -0,0 +1,62 @@ +public class WithByTypes { + private final int a; + private final long b; + private final short c; + private final char d; + private final byte e; + private final double f; + private final float g; + private final boolean h; + private final T i; + public static void example() { + new WithByTypes(0, 0, (short) 0, ' ', (byte) 0, 0.0, 0.0F, true, "").withHBy(x -> !x).withFBy(x -> x + 0.5); + } + @java.lang.SuppressWarnings("all") + public WithByTypes(final int a, final long b, final short c, final char d, final byte e, final double f, final float g, final boolean h, final T i) { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.e = e; + this.f = f; + this.g = g; + this.h = h; + this.i = i; + } + @java.lang.SuppressWarnings("all") + public WithByTypes withABy(final java.util.function.IntUnaryOperator transformer) { + return new WithByTypes(transformer.applyAsInt(this.a), this.b, this.c, this.d, this.e, this.f, this.g, this.h, this.i); + } + @java.lang.SuppressWarnings("all") + public WithByTypes withBBy(final java.util.function.LongUnaryOperator transformer) { + return new WithByTypes(this.a, transformer.applyAsLong(this.b), this.c, this.d, this.e, this.f, this.g, this.h, this.i); + } + @java.lang.SuppressWarnings("all") + public WithByTypes withCBy(final java.util.function.IntUnaryOperator transformer) { + return new WithByTypes(this.a, this.b, (short) transformer.applyAsInt(this.c), this.d, this.e, this.f, this.g, this.h, this.i); + } + @java.lang.SuppressWarnings("all") + public WithByTypes withDBy(final java.util.function.IntUnaryOperator transformer) { + return new WithByTypes(this.a, this.b, this.c, (char) transformer.applyAsInt(this.d), this.e, this.f, this.g, this.h, this.i); + } + @java.lang.SuppressWarnings("all") + public WithByTypes withEBy(final java.util.function.IntUnaryOperator transformer) { + return new WithByTypes(this.a, this.b, this.c, this.d, (byte) transformer.applyAsInt(this.e), this.f, this.g, this.h, this.i); + } + @java.lang.SuppressWarnings("all") + public WithByTypes withFBy(final java.util.function.DoubleUnaryOperator transformer) { + return new WithByTypes(this.a, this.b, this.c, this.d, this.e, transformer.applyAsDouble(this.f), this.g, this.h, this.i); + } + @java.lang.SuppressWarnings("all") + public WithByTypes withGBy(final java.util.function.DoubleUnaryOperator transformer) { + return new WithByTypes(this.a, this.b, this.c, this.d, this.e, this.f, (float) transformer.applyAsDouble(this.g), this.h, this.i); + } + @java.lang.SuppressWarnings("all") + public WithByTypes withHBy(final java.util.function.UnaryOperator transformer) { + return new WithByTypes(this.a, this.b, this.c, this.d, this.e, this.f, this.g, transformer.apply(this.h), this.i); + } + @java.lang.SuppressWarnings("all") + public WithByTypes withIBy(final java.util.function.Function transformer) { + return new WithByTypes(this.a, this.b, this.c, this.d, this.e, this.f, this.g, this.h, transformer.apply(this.i)); + } +} \ No newline at end of file diff --git a/test/transform/resource/before/WithByNullAnnos.java b/test/transform/resource/before/WithByNullAnnos.java new file mode 100644 index 00000000..3fd8087f --- /dev/null +++ b/test/transform/resource/before/WithByNullAnnos.java @@ -0,0 +1,6 @@ +//CONF: lombok.addNullAnnotations=checkerframework +import java.util.List; +@lombok.RequiredArgsConstructor +public class WithByNullAnnos { + @lombok.experimental.WithBy final List test; +} diff --git a/test/transform/resource/before/WithByTypes.java b/test/transform/resource/before/WithByTypes.java new file mode 100644 index 00000000..9d2fe358 --- /dev/null +++ b/test/transform/resource/before/WithByTypes.java @@ -0,0 +1,18 @@ +@lombok.RequiredArgsConstructor +@lombok.experimental.FieldDefaults(level = lombok.AccessLevel.PRIVATE, makeFinal = true) +@lombok.experimental.WithBy +public class WithByTypes { + int a; + long b; + short c; + char d; + byte e; + double f; + float g; + boolean h; + T i; + + public static void example() { + new WithByTypes(0, 0, (short) 0, ' ', (byte) 0, 0.0, 0.0F, true, "").withHBy(x -> !x).withFBy(x -> x + 0.5); + } +} -- cgit