From 5b4ab9dae8940973ce8b87c8c2a0388b768dac89 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 20 Jan 2015 15:01:30 +0100 Subject: added the ‘always use guava’ lombok.config option for @Singular @Builder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BuilderSingletonRedirectToGuava.java | 75 ++++++++++++++++++++++ .../after-ecj/BuilderSingletonRedirectToGuava.java | 71 ++++++++++++++++++++ .../before/BuilderSingletonRedirectToGuava.java | 13 ++++ .../src/lombok/transform/TestWithEcj.java | 4 -- 4 files changed, 159 insertions(+), 4 deletions(-) create mode 100644 test/transform/resource/after-delombok/BuilderSingletonRedirectToGuava.java create mode 100644 test/transform/resource/after-ecj/BuilderSingletonRedirectToGuava.java create mode 100644 test/transform/resource/before/BuilderSingletonRedirectToGuava.java (limited to 'test/transform') diff --git a/test/transform/resource/after-delombok/BuilderSingletonRedirectToGuava.java b/test/transform/resource/after-delombok/BuilderSingletonRedirectToGuava.java new file mode 100644 index 00000000..a2d230a1 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingletonRedirectToGuava.java @@ -0,0 +1,75 @@ +import java.util.Set; +import java.util.NavigableMap; +import java.util.Collection; +class BuilderSingletonRedirectToGuava { + private Set dangerMice; + private NavigableMap things; + private Collection> doohickeys; + @java.lang.SuppressWarnings("all") + BuilderSingletonRedirectToGuava(final Set dangerMice, final NavigableMap things, final Collection> doohickeys) { + this.dangerMice = dangerMice; + this.things = things; + this.doohickeys = doohickeys; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingletonRedirectToGuavaBuilder { + private com.google.common.collect.ImmutableSet.Builder dangerMice; + private com.google.common.collect.ImmutableSortedMap.Builder things; + private com.google.common.collect.ImmutableList.Builder> doohickeys; + @java.lang.SuppressWarnings("all") + BuilderSingletonRedirectToGuavaBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingletonRedirectToGuavaBuilder dangerMouse(final String dangerMouse) { + if (this.dangerMice == null) this.dangerMice = com.google.common.collect.ImmutableSet.builder(); + this.dangerMice.add(dangerMouse); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingletonRedirectToGuavaBuilder dangerMice(final java.lang.Iterable dangerMice) { + if (this.dangerMice == null) this.dangerMice = com.google.common.collect.ImmutableSet.builder(); + this.dangerMice.addAll(dangerMice); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingletonRedirectToGuavaBuilder thing(final Integer thing$key, final Number thing$value) { + if (this.things == null) this.things = com.google.common.collect.ImmutableSortedMap.naturalOrder(); + this.things.put(thing$key, thing$value); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingletonRedirectToGuavaBuilder things(final java.util.Map things) { + if (this.things == null) this.things = com.google.common.collect.ImmutableSortedMap.naturalOrder(); + this.things.putAll(things); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingletonRedirectToGuavaBuilder doohickey(final Class doohickey) { + if (this.doohickeys == null) this.doohickeys = com.google.common.collect.ImmutableList.builder(); + this.doohickeys.add(doohickey); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingletonRedirectToGuavaBuilder doohickeys(final java.lang.Iterable> doohickeys) { + if (this.doohickeys == null) this.doohickeys = com.google.common.collect.ImmutableList.builder(); + this.doohickeys.addAll(doohickeys); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingletonRedirectToGuava build() { + java.util.Set dangerMice = this.dangerMice == null ? com.google.common.collect.ImmutableSet.of() : this.dangerMice.build(); + java.util.NavigableMap things = this.things == null ? com.google.common.collect.ImmutableSortedMap.of() : this.things.build(); + java.util.Collection> doohickeys = this.doohickeys == null ? com.google.common.collect.ImmutableList.of() : this.doohickeys.build(); + return new BuilderSingletonRedirectToGuava(dangerMice, things, doohickeys); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingletonRedirectToGuava.BuilderSingletonRedirectToGuavaBuilder(dangerMice=" + this.dangerMice + ", things=" + this.things + ", doohickeys=" + this.doohickeys + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingletonRedirectToGuavaBuilder builder() { + return new BuilderSingletonRedirectToGuavaBuilder(); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/BuilderSingletonRedirectToGuava.java b/test/transform/resource/after-ecj/BuilderSingletonRedirectToGuava.java new file mode 100644 index 00000000..ce8fab10 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingletonRedirectToGuava.java @@ -0,0 +1,71 @@ +import java.util.Set; +import java.util.NavigableMap; +import java.util.Collection; +import lombok.Singular; +@lombok.Builder class BuilderSingletonRedirectToGuava { + public static @java.lang.SuppressWarnings("all") class BuilderSingletonRedirectToGuavaBuilder { + private com.google.common.collect.ImmutableSet.Builder dangerMice; + private com.google.common.collect.ImmutableSortedMap.Builder things; + private com.google.common.collect.ImmutableList.Builder> doohickeys; + @java.lang.SuppressWarnings("all") BuilderSingletonRedirectToGuavaBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingletonRedirectToGuavaBuilder dangerMouse(String dangerMouse) { + if ((this.dangerMice == null)) + this.dangerMice = com.google.common.collect.ImmutableSet.builder(); + this.dangerMice.add(dangerMouse); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingletonRedirectToGuavaBuilder dangerMice(java.lang.Iterable dangerMice) { + if ((this.dangerMice == null)) + this.dangerMice = com.google.common.collect.ImmutableSet.builder(); + this.dangerMice.addAll(dangerMice); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingletonRedirectToGuavaBuilder thing(Integer thing$key, Number thing$value) { + if ((this.things == null)) + this.things = com.google.common.collect.ImmutableSortedMap.naturalOrder(); + this.things.put(thing$key, thing$value); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingletonRedirectToGuavaBuilder things(java.util.Map things) { + if ((this.things == null)) + this.things = com.google.common.collect.ImmutableSortedMap.naturalOrder(); + this.things.putAll(things); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingletonRedirectToGuavaBuilder doohickey(Class doohickey) { + if ((this.doohickeys == null)) + this.doohickeys = com.google.common.collect.ImmutableList.builder(); + this.doohickeys.add(doohickey); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingletonRedirectToGuavaBuilder doohickeys(java.lang.Iterable> doohickeys) { + if ((this.doohickeys == null)) + this.doohickeys = com.google.common.collect.ImmutableList.builder(); + this.doohickeys.addAll(doohickeys); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingletonRedirectToGuava build() { + java.util.Set dangerMice = ((this.dangerMice == null) ? com.google.common.collect.ImmutableSet.of() : this.dangerMice.build()); + java.util.NavigableMap things = ((this.things == null) ? com.google.common.collect.ImmutableSortedMap.of() : this.things.build()); + java.util.Collection> doohickeys = ((this.doohickeys == null) ? com.google.common.collect.ImmutableList.of() : this.doohickeys.build()); + return new BuilderSingletonRedirectToGuava(dangerMice, things, doohickeys); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((("BuilderSingletonRedirectToGuava.BuilderSingletonRedirectToGuavaBuilder(dangerMice=" + this.dangerMice) + ", things=") + this.things) + ", doohickeys=") + this.doohickeys) + ")"); + } + } + private @Singular Set dangerMice; + private @Singular NavigableMap things; + private @Singular Collection> doohickeys; + @java.lang.SuppressWarnings("all") BuilderSingletonRedirectToGuava(final Set dangerMice, final NavigableMap things, final Collection> doohickeys) { + super(); + this.dangerMice = dangerMice; + this.things = things; + this.doohickeys = doohickeys; + } + public static @java.lang.SuppressWarnings("all") BuilderSingletonRedirectToGuavaBuilder builder() { + return new BuilderSingletonRedirectToGuavaBuilder(); + } +} \ No newline at end of file diff --git a/test/transform/resource/before/BuilderSingletonRedirectToGuava.java b/test/transform/resource/before/BuilderSingletonRedirectToGuava.java new file mode 100644 index 00000000..0429f0ed --- /dev/null +++ b/test/transform/resource/before/BuilderSingletonRedirectToGuava.java @@ -0,0 +1,13 @@ +//CONF: lombok.builder.useGuava = true +import java.util.Set; +import java.util.NavigableMap; +import java.util.Collection; + +import lombok.Singular; + +@lombok.Builder +class BuilderSingletonRedirectToGuava { + @Singular private Set dangerMice; + @Singular private NavigableMap things; + @Singular private Collection> doohickeys; +} diff --git a/test/transform/src/lombok/transform/TestWithEcj.java b/test/transform/src/lombok/transform/TestWithEcj.java index 4c3f6bf8..0a4057dd 100644 --- a/test/transform/src/lombok/transform/TestWithEcj.java +++ b/test/transform/src/lombok/transform/TestWithEcj.java @@ -57,8 +57,4 @@ public class TestWithEcj extends DirectoryRunner.TestParams { public File getMessagesDirectory() { return new File("test/transform/resource/messages-ecj"); } - - @Override public boolean accept(File file) { - return file.getName().startsWith("BuilderSingleton"); - } } -- cgit