From 96151ade650c2038ab639a1c0f5a504747c4b1b5 Mon Sep 17 00:00:00 2001 From: Caleb Brinkman Date: Wed, 10 Jul 2019 15:05:06 -0500 Subject: Add tests for prefixed builder --- .../resource/after-delombok/BuilderWithPrefix.java | 34 ++++++++++++++++++++++ .../resource/after-ecj/BuilderWithPrefix.java | 27 +++++++++++++++++ .../resource/before/BuilderWithPrefix.java | 6 ++++ 3 files changed, 67 insertions(+) create mode 100644 test/transform/resource/after-delombok/BuilderWithPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderWithPrefix.java create mode 100644 test/transform/resource/before/BuilderWithPrefix.java (limited to 'test/transform') diff --git a/test/transform/resource/after-delombok/BuilderWithPrefix.java b/test/transform/resource/after-delombok/BuilderWithPrefix.java new file mode 100644 index 00000000..c29d2a16 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithPrefix.java @@ -0,0 +1,34 @@ +import java.util.List; +class BuilderWithPrefix { + private int unprefixed; + @java.lang.SuppressWarnings("all") + BuilderWithPrefix(final int unprefixed) { + this.unprefixed = unprefixed; + } + @java.lang.SuppressWarnings("all") + protected static class BuilderWithPrefixBuilder { + @java.lang.SuppressWarnings("all") + private int unprefixed; + @java.lang.SuppressWarnings("all") + BuilderWithPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderWithPrefixBuilder withUnprefixed(final int unprefixed) { + this.unprefixed = unprefixed; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithPrefix build() { + return new BuilderWithPrefix(unprefixed); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithPrefix.BuilderWithPrefixBuilder(unprefixed=" + this.unprefixed + ")"; + } + } + @java.lang.SuppressWarnings("all") + protected static BuilderWithPrefixBuilder builder() { + return new BuilderWithPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderWithPrefix.java b/test/transform/resource/after-ecj/BuilderWithPrefix.java new file mode 100644 index 00000000..21a60d0d --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithPrefix.java @@ -0,0 +1,27 @@ +import java.util.List; +@lombok.Builder(access = lombok.AccessLevel.PROTECTED,setterPrefix = "with") class BuilderWithPrefix { + protected static @java.lang.SuppressWarnings("all") class BuilderWithPrefixBuilder { + private @java.lang.SuppressWarnings("all") int unprefixed; + @java.lang.SuppressWarnings("all") BuilderWithPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderWithPrefixBuilder withUnprefixed(final int unprefixed) { + this.unprefixed = unprefixed; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithPrefix build() { + return new BuilderWithPrefix(unprefixed); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((("BuilderWithPrefix.BuilderWithPrefixBuilder(unprefixed=" + this.unprefixed) + ")"); + } + } + private int unprefixed; + @java.lang.SuppressWarnings("all") BuilderWithPrefix(final int unprefixed) { + super(); + this.unprefixed = unprefixed; + } + protected static @java.lang.SuppressWarnings("all") BuilderWithPrefixBuilder builder() { + return new BuilderWithPrefixBuilder(); + } +} diff --git a/test/transform/resource/before/BuilderWithPrefix.java b/test/transform/resource/before/BuilderWithPrefix.java new file mode 100644 index 00000000..38f3c029 --- /dev/null +++ b/test/transform/resource/before/BuilderWithPrefix.java @@ -0,0 +1,6 @@ +import java.util.List; + +@lombok.Builder(access = lombok.AccessLevel.PROTECTED, setterPrefix = "with") +class BuilderWithPrefix { + private int unprefixed; +} -- cgit From 88bf742e3e107cc0bbfc3a72c2f456d34ef3079c Mon Sep 17 00:00:00 2001 From: Caleb Brinkman Date: Wed, 10 Jul 2019 17:27:01 -0500 Subject: Implement prefixed setters Related to #1805, this change adds an optional `setterPrefix` parameter to the `Builder` annotation; if this parameter is unspecified or blank the behavior of the `Builder` annotation is unchanged, but if it is present the value specified will be prefixed to the generated methods. For example, using: ``` @Builder(setterPrefix = "include") class Foo { private int someValue; } ``` will result in a generated `Builder` class containing an `includeSomeValue(int someValue)` method instead of the default `someValue(int someValue)`. --- test/transform/resource/after-ecj/BuilderWithPrefix.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/transform') diff --git a/test/transform/resource/after-ecj/BuilderWithPrefix.java b/test/transform/resource/after-ecj/BuilderWithPrefix.java index 21a60d0d..98c42fe9 100644 --- a/test/transform/resource/after-ecj/BuilderWithPrefix.java +++ b/test/transform/resource/after-ecj/BuilderWithPrefix.java @@ -13,7 +13,7 @@ import java.util.List; return new BuilderWithPrefix(unprefixed); } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { - return (((("BuilderWithPrefix.BuilderWithPrefixBuilder(unprefixed=" + this.unprefixed) + ")"); + return (("BuilderWithPrefix.BuilderWithPrefixBuilder(unprefixed=" + this.unprefixed) + ")"); } } private int unprefixed; -- cgit From 36287f2ff9ed2f809f8c1c76155919417ad04d3c Mon Sep 17 00:00:00 2001 From: Caleb Brinkman Date: Thu, 12 Sep 2019 11:27:08 -0500 Subject: Duplicate builder tests with setter prefix --- .../BuilderSimpleWithSetterPrefix.java | 34 ++++ ...lderSingularAnnotatedTypesWithSetterPrefix.java | 124 ++++++++++++ ...lderSingularGuavaListsSetsWithSetterPrefix.java | 140 ++++++++++++++ .../BuilderSingularListsWithSetterPrefix.java | 123 ++++++++++++ .../BuilderSingularMapsWithSetterPrefix.java | 213 +++++++++++++++++++++ .../BuilderSingularNoAutoWithSetterPrefix.java | 121 ++++++++++++ ...derSingularRedirectToGuavaWithSetterPrefix.java | 93 +++++++++ .../BuilderSingularSetsWithPrefix.java | 153 +++++++++++++++ ...rSingularToBuilderWithNullWithSetterPrefix.java | 65 +++++++ ...WildcardListsWithToBuilderWithSetterPrefix.java | 97 ++++++++++ ...uilderSingularWithPrefixesWithSetterPrefix.java | 56 ++++++ .../BuilderTypeAnnosWithSetterPrefix.java | 45 +++++ .../BuilderValueDataWithSetterPrefix.java | 109 +++++++++++ .../BuilderWithAccessorsWithSetterPrefix.java | 60 ++++++ .../BuilderWithBadNamesWithSetterPrefix.java | 42 ++++ .../BuilderWithDeprecatedWithSetterPrefix.java | 114 +++++++++++ ...erWithExistingBuilderClassWithSetterPrefix.java | 40 ++++ ...BuilderWithNoBuilderMethodWithSetterPrefix.java | 33 ++++ .../BuilderWithNonNullWithSetterPrefix.java | 40 ++++ .../resource/after-delombok/BuilderWithPrefix.java | 34 ---- ...ilderWithRecursiveGenericsWithSetterPrefix.java | 85 ++++++++ .../BuilderWithToBuilderWithSetterPrefix.java | 146 ++++++++++++++ .../BuilderWithTolerateWithSetterPrefix.java | 40 ++++ .../after-ecj/BuilderSimpleWithSetterPrefix.java | 27 +++ ...lderSingularAnnotatedTypesWithSetterPrefix.java | 121 ++++++++++++ ...lderSingularGuavaListsSetsWithSetterPrefix.java | 125 ++++++++++++ .../BuilderSingularGuavaMapsWithSetterPrefix.java | 83 ++++++++ .../BuilderSingularListsWithSetterPrefix.java | 116 +++++++++++ .../BuilderSingularMapsWithSetterPrefix.java | 209 ++++++++++++++++++++ .../BuilderSingularNoAutoWithSetterPrefix.java | 114 +++++++++++ ...derSingularRedirectToGuavaWithSetterPrefix.java | 83 ++++++++ .../BuilderSingularSetsWithSetterPrefix.java | 145 ++++++++++++++ ...rSingularToBuilderWithNullWithSetterPrefix.java | 60 ++++++ ...WildcardListsWithToBuilderWithSetterPrefix.java | 92 +++++++++ ...uilderSingularWithPrefixesWithSetterPrefix.java | 51 +++++ .../BuilderTypeAnnosWithSetterPrefix.java | 33 ++++ .../BuilderValueDataWithSetterPrefix.java | 90 +++++++++ .../BuilderWithAccessorsWithSetterPrefix.java | 47 +++++ .../BuilderWithBadNamesWithSetterPrefix.java | 33 ++++ .../BuilderWithDeprecatedWithSetterPrefix.java | 87 +++++++++ ...erWithExistingBuilderClassWithSetterPrefix.java | 36 ++++ ...BuilderWithNoBuilderMethodWithSetterPrefix.java | 27 +++ .../BuilderWithNonNullWithSetterPrefix.java | 34 ++++ .../resource/after-ecj/BuilderWithPrefix.java | 27 --- ...ilderWithRecursiveGenericsWithSetterPrefix.java | 78 ++++++++ .../BuilderWithToBuilderWithSetterPrefix.java | 123 ++++++++++++ .../BuilderWithTolerateWithSetterPrefix.java | 34 ++++ .../before/BuilderSimpleWithSetterPrefix.java | 6 + ...lderSingularAnnotatedTypesWithSetterPrefix.java | 14 ++ ...lderSingularGuavaListsSetsWithSetterPrefix.java | 16 ++ .../before/BuilderSingularGuavaMapsWithPrefix.java | 12 ++ .../BuilderSingularListsWithSetterPrefix.java | 11 ++ .../BuilderSingularMapsWithSetterPrefix.java | 15 ++ .../BuilderSingularNoAutoWithSetterPrefix.java | 11 ++ ...derSingularRedirectToGuavaWithSetterPrefix.java | 13 ++ .../BuilderSingularSetsWithSetterPrefix.java | 12 ++ ...rSingularToBuilderWithNullWithSetterPrefix.java | 10 + ...WildcardListsWithToBuilderWithSetterPrefix.java | 10 + ...uilderSingularWithPrefixesWithSetterPrefix.java | 7 + .../before/BuilderTypeAnnosWithSetterPrefix.java | 14 ++ .../before/BuilderValueDataWithSetterPrefix.java | 11 ++ .../BuilderWithAccessorsWithSetterPrefix.java | 7 + .../BuilderWithBadNamesWithSetterPrefix.java | 5 + .../BuilderWithDeprecatedWithSetterPrefix.java | 11 ++ ...erWithExistingBuilderClassWithSetterPrefix.java | 15 ++ ...BuilderWithNoBuilderMethodWithSetterPrefix.java | 5 + .../before/BuilderWithNonNullWithSetterPrefix.java | 5 + .../resource/before/BuilderWithPrefix.java | 6 - ...ilderWithRecursiveGenericsWithSetterPrefix.java | 13 ++ .../BuilderWithToBuilderWithSetterPrefix.java | 20 ++ .../BuilderWithTolerateWithSetterPrefix.java | 18 ++ 71 files changed, 4082 insertions(+), 67 deletions(-) create mode 100644 test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularGuavaListsSetsWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularListsWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularMapsWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularRedirectToGuavaWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularSetsWithPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularToBuilderWithNullWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderSingularWithPrefixesWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderTypeAnnosWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderValueDataWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderWithAccessorsWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderWithBadNamesWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderWithDeprecatedWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderWithExistingBuilderClassWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderWithNoBuilderMethodWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderWithNonNullWithSetterPrefix.java delete mode 100644 test/transform/resource/after-delombok/BuilderWithPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderWithRecursiveGenericsWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderWithToBuilderWithSetterPrefix.java create mode 100644 test/transform/resource/after-delombok/BuilderWithTolerateWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSimpleWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularAnnotatedTypesWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularGuavaListsSetsWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularGuavaMapsWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularListsWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularMapsWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularNoAutoWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularRedirectToGuavaWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularSetsWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularToBuilderWithNullWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderSingularWithPrefixesWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderTypeAnnosWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderValueDataWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderWithAccessorsWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderWithBadNamesWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderWithDeprecatedWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderWithExistingBuilderClassWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderWithNoBuilderMethodWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderWithNonNullWithSetterPrefix.java delete mode 100644 test/transform/resource/after-ecj/BuilderWithPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderWithRecursiveGenericsWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderWithToBuilderWithSetterPrefix.java create mode 100644 test/transform/resource/after-ecj/BuilderWithTolerateWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSimpleWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularAnnotatedTypesWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularGuavaListsSetsWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularGuavaMapsWithPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularListsWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularMapsWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularNoAutoWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularRedirectToGuavaWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularSetsWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularToBuilderWithNullWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderSingularWithPrefixesWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderTypeAnnosWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderValueDataWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderWithAccessorsWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderWithBadNamesWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderWithDeprecatedWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderWithExistingBuilderClassWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderWithNoBuilderMethodWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderWithNonNullWithSetterPrefix.java delete mode 100644 test/transform/resource/before/BuilderWithPrefix.java create mode 100644 test/transform/resource/before/BuilderWithRecursiveGenericsWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderWithToBuilderWithSetterPrefix.java create mode 100644 test/transform/resource/before/BuilderWithTolerateWithSetterPrefix.java (limited to 'test/transform') diff --git a/test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java new file mode 100644 index 00000000..c29d2a16 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java @@ -0,0 +1,34 @@ +import java.util.List; +class BuilderWithPrefix { + private int unprefixed; + @java.lang.SuppressWarnings("all") + BuilderWithPrefix(final int unprefixed) { + this.unprefixed = unprefixed; + } + @java.lang.SuppressWarnings("all") + protected static class BuilderWithPrefixBuilder { + @java.lang.SuppressWarnings("all") + private int unprefixed; + @java.lang.SuppressWarnings("all") + BuilderWithPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderWithPrefixBuilder withUnprefixed(final int unprefixed) { + this.unprefixed = unprefixed; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithPrefix build() { + return new BuilderWithPrefix(unprefixed); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithPrefix.BuilderWithPrefixBuilder(unprefixed=" + this.unprefixed + ")"; + } + } + @java.lang.SuppressWarnings("all") + protected static BuilderWithPrefixBuilder builder() { + return new BuilderWithPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java new file mode 100644 index 00000000..2d535e65 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java @@ -0,0 +1,124 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.util.Set; +import java.util.Map; +import lombok.NonNull; +@Target(ElementType.TYPE_USE) +@interface MyAnnotation { +} +class BuilderSingularAnnotatedTypes { + private Set<@MyAnnotation @NonNull String> foos; + private Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars; + @java.lang.SuppressWarnings("all") + BuilderSingularAnnotatedTypes(final Set<@MyAnnotation @NonNull String> foos, final Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars) { + this.foos = foos; + this.bars = bars; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingularAnnotatedTypesBuilder { + @java.lang.SuppressWarnings("all") + private java.util.ArrayList<@MyAnnotation @NonNull String> foos; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList<@MyAnnotation @NonNull String> bars$key; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList<@MyAnnotation @NonNull Integer> bars$value; + @java.lang.SuppressWarnings("all") + BuilderSingularAnnotatedTypesBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularAnnotatedTypesBuilder withFoo(@MyAnnotation @NonNull final String foo) { + if (foo == null) { + throw new java.lang.NullPointerException("foo is marked non-null but is null"); + } + if (this.foos == null) this.foos = new java.util.ArrayList<@MyAnnotation @NonNull String>(); + this.foos.add(foo); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularAnnotatedTypesBuilder withFoos(final java.util.Collection foos) { + if (this.foos == null) this.foos = new java.util.ArrayList<@MyAnnotation @NonNull String>(); + this.foos.addAll(foos); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularAnnotatedTypesBuilder clearFoos() { + if (this.foos != null) this.foos.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularAnnotatedTypesBuilder withBar(@MyAnnotation @NonNull final String barKey, @MyAnnotation @NonNull final Integer barValue) { + if (barKey == null) { + throw new java.lang.NullPointerException("barKey is marked non-null but is null"); + } + if (barValue == null) { + throw new java.lang.NullPointerException("barValue is marked non-null but is null"); + } + if (this.bars$key == null) { + this.bars$key = new java.util.ArrayList<@MyAnnotation @NonNull String>(); + this.bars$value = new java.util.ArrayList<@MyAnnotation @NonNull Integer>(); + } + this.bars$key.add(barKey); + this.bars$value.add(barValue); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularAnnotatedTypesBuilder withBars(final java.util.Map bars) { + if (this.bars$key == null) { + this.bars$key = new java.util.ArrayList<@MyAnnotation @NonNull String>(); + this.bars$value = new java.util.ArrayList<@MyAnnotation @NonNull Integer>(); + } + for (final java.util.Map.Entry $lombokEntry : bars.entrySet()) { + this.bars$key.add($lombokEntry.getKey()); + this.bars$value.add($lombokEntry.getValue()); + } + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularAnnotatedTypesBuilder clearBars() { + if (this.bars$key != null) { + this.bars$key.clear(); + this.bars$value.clear(); + } + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularAnnotatedTypes build() { + java.util.Set<@MyAnnotation @NonNull String> foos; + switch (this.foos == null ? 0 : this.foos.size()) { + case 0: + foos = java.util.Collections.emptySet(); + break; + case 1: + foos = java.util.Collections.singleton(this.foos.get(0)); + break; + default: + foos = new java.util.LinkedHashSet<@MyAnnotation @NonNull String>(this.foos.size() < 1073741824 ? 1 + this.foos.size() + (this.foos.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); + foos.addAll(this.foos); + foos = java.util.Collections.unmodifiableSet(foos); + } + java.util.Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars; + switch (this.bars$key == null ? 0 : this.bars$key.size()) { + case 0: + bars = java.util.Collections.emptyMap(); + break; + case 1: + bars = java.util.Collections.singletonMap(this.bars$key.get(0), this.bars$value.get(0)); + break; + default: + bars = new java.util.LinkedHashMap<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer>(this.bars$key.size() < 1073741824 ? 1 + this.bars$key.size() + (this.bars$key.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); + for (int $i = 0; $i < this.bars$key.size(); $i++) bars.put(this.bars$key.get($i), (@MyAnnotation @NonNull Integer) this.bars$value.get($i)); + bars = java.util.Collections.unmodifiableMap(bars); + } + return new BuilderSingularAnnotatedTypes(foos, bars); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularAnnotatedTypes.BuilderSingularAnnotatedTypesBuilder(foos=" + this.foos + ", bars$key=" + this.bars$key + ", bars$value=" + this.bars$value + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularAnnotatedTypesBuilder builder() { + return new BuilderSingularAnnotatedTypesBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularGuavaListsSetsWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularGuavaListsSetsWithSetterPrefix.java new file mode 100644 index 00000000..0e9e6dfd --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularGuavaListsSetsWithSetterPrefix.java @@ -0,0 +1,140 @@ +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableCollection; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; +import com.google.common.collect.ImmutableTable; +class BuilderSingularGuavaListsSets { + private ImmutableList cards; + private ImmutableCollection frogs; + @SuppressWarnings("all") + private ImmutableSet rawSet; + private ImmutableSortedSet passes; + private ImmutableTable users; + @java.lang.SuppressWarnings("all") + BuilderSingularGuavaListsSets(final ImmutableList cards, final ImmutableCollection frogs, final ImmutableSet rawSet, final ImmutableSortedSet passes, final ImmutableTable users) { + this.cards = cards; + this.frogs = frogs; + this.rawSet = rawSet; + this.passes = passes; + this.users = users; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingularGuavaListsSetsBuilder { + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableList.Builder cards; + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableList.Builder frogs; + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableSet.Builder rawSet; + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableSortedSet.Builder passes; + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableTable.Builder users; + @java.lang.SuppressWarnings("all") + BuilderSingularGuavaListsSetsBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder withCard(final T card) { + if (this.cards == null) this.cards = com.google.common.collect.ImmutableList.builder(); + this.cards.add(card); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder withCards(final java.lang.Iterable cards) { + if (this.cards == null) this.cards = com.google.common.collect.ImmutableList.builder(); + this.cards.addAll(cards); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder clearCards() { + this.cards = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder withFrog(final Number frog) { + if (this.frogs == null) this.frogs = com.google.common.collect.ImmutableList.builder(); + this.frogs.add(frog); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder withFrogs(final java.lang.Iterable frogs) { + if (this.frogs == null) this.frogs = com.google.common.collect.ImmutableList.builder(); + this.frogs.addAll(frogs); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder clearFrogs() { + this.frogs = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder withRawSet(final java.lang.Object rawSet) { + if (this.rawSet == null) this.rawSet = com.google.common.collect.ImmutableSet.builder(); + this.rawSet.add(rawSet); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder withRawSet(final java.lang.Iterable rawSet) { + if (this.rawSet == null) this.rawSet = com.google.common.collect.ImmutableSet.builder(); + this.rawSet.addAll(rawSet); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder clearRawSet() { + this.rawSet = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder withPass(final String pass) { + if (this.passes == null) this.passes = com.google.common.collect.ImmutableSortedSet.naturalOrder(); + this.passes.add(pass); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder withPasses(final java.lang.Iterable passes) { + if (this.passes == null) this.passes = com.google.common.collect.ImmutableSortedSet.naturalOrder(); + this.passes.addAll(passes); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder clearPasses() { + this.passes = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder withUser(final Number rowKey, final Number columnKey, final String value) { + if (this.users == null) this.users = com.google.common.collect.ImmutableTable.builder(); + this.users.put(rowKey, columnKey, value); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder withUsers(final com.google.common.collect.Table users) { + if (this.users == null) this.users = com.google.common.collect.ImmutableTable.builder(); + this.users.putAll(users); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsBuilder clearUsers() { + this.users = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSets build() { + com.google.common.collect.ImmutableList cards = this.cards == null ? com.google.common.collect.ImmutableList.of() : this.cards.build(); + com.google.common.collect.ImmutableCollection frogs = this.frogs == null ? com.google.common.collect.ImmutableList.of() : this.frogs.build(); + com.google.common.collect.ImmutableSet rawSet = this.rawSet == null ? com.google.common.collect.ImmutableSet.of() : this.rawSet.build(); + com.google.common.collect.ImmutableSortedSet passes = this.passes == null ? com.google.common.collect.ImmutableSortedSet.of() : this.passes.build(); + com.google.common.collect.ImmutableTable users = this.users == null ? com.google.common.collect.ImmutableTable.of() : this.users.build(); + return new BuilderSingularGuavaListsSets(cards, frogs, rawSet, passes, users); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularGuavaListsSets.BuilderSingularGuavaListsSetsBuilder(cards=" + this.cards + ", frogs=" + this.frogs + ", rawSet=" + this.rawSet + ", passes=" + this.passes + ", users=" + this.users + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularGuavaListsSetsBuilder builder() { + return new BuilderSingularGuavaListsSetsBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularListsWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularListsWithSetterPrefix.java new file mode 100644 index 00000000..1fd58406 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularListsWithSetterPrefix.java @@ -0,0 +1,123 @@ +import java.util.List; +import java.util.Collection; +class BuilderSingularLists { + private List children; + private Collection scarves; + @SuppressWarnings("all") + private List rawList; + @java.lang.SuppressWarnings("all") + BuilderSingularLists(final List children, final Collection scarves, final List rawList) { + this.children = children; + this.scarves = scarves; + this.rawList = rawList; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingularListsBuilder { + @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") + BuilderSingularListsBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsBuilder withChild(final T child) { + if (this.children == null) this.children = new java.util.ArrayList(); + this.children.add(child); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsBuilder withChildren(final java.util.Collection children) { + if (this.children == null) this.children = new java.util.ArrayList(); + this.children.addAll(children); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsBuilder clearChildren() { + if (this.children != null) this.children.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsBuilder withScarf(final Number scarf) { + if (this.scarves == null) this.scarves = new java.util.ArrayList(); + this.scarves.add(scarf); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsBuilder withScarves(final java.util.Collection scarves) { + if (this.scarves == null) this.scarves = new java.util.ArrayList(); + this.scarves.addAll(scarves); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsBuilder clearScarves() { + if (this.scarves != null) this.scarves.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsBuilder withRawList(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 BuilderSingularListsBuilder withRawList(final java.util.Collection rawList) { + if (this.rawList == null) this.rawList = new java.util.ArrayList(); + this.rawList.addAll(rawList); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsBuilder clearRawList() { + if (this.rawList != null) this.rawList.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularLists 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 BuilderSingularLists(children, scarves, rawList); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularLists.BuilderSingularListsBuilder(children=" + this.children + ", scarves=" + this.scarves + ", rawList=" + this.rawList + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularListsBuilder builder() { + return new BuilderSingularListsBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularMapsWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularMapsWithSetterPrefix.java new file mode 100644 index 00000000..4b250994 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularMapsWithSetterPrefix.java @@ -0,0 +1,213 @@ +import java.util.Map; +import java.util.SortedMap; +class BuilderSingularMaps { + private Map women; + private SortedMap men; + @SuppressWarnings("all") + private Map rawMap; + private Map stringMap; + @SuppressWarnings("all") + BuilderSingularMaps(Map women, SortedMap men, Map rawMap, Map stringMap) { + this.women = women; + this.men = men; + this.rawMap = rawMap; + this.stringMap = stringMap; + } + @SuppressWarnings("all") + public static class BuilderSingularMapsBuilder { + @SuppressWarnings("all") + private java.util.ArrayList women$key; + @SuppressWarnings("all") + private java.util.ArrayList women$value; + @SuppressWarnings("all") + private java.util.ArrayList men$key; + @SuppressWarnings("all") + private java.util.ArrayList men$value; + @SuppressWarnings("all") + private java.util.ArrayList rawMap$key; + @SuppressWarnings("all") + private java.util.ArrayList rawMap$value; + @SuppressWarnings("all") + private java.util.ArrayList stringMap$key; + @SuppressWarnings("all") + private java.util.ArrayList stringMap$value; + @SuppressWarnings("all") + BuilderSingularMapsBuilder() { + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder withWoman(K womanKey, V womanValue) { + if (this.women$key == null) { + this.women$key = new java.util.ArrayList(); + this.women$value = new java.util.ArrayList(); + } + this.women$key.add(womanKey); + this.women$value.add(womanValue); + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder withWomen(java.util.Map women) { + if (this.women$key == null) { + this.women$key = new java.util.ArrayList(); + this.women$value = new java.util.ArrayList(); + } + for (java.util.Map.Entry $lombokEntry : women.entrySet()) { + this.women$key.add($lombokEntry.getKey()); + this.women$value.add($lombokEntry.getValue()); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder clearWomen() { + if (this.women$key != null) { + this.women$key.clear(); + this.women$value.clear(); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder withMan(K manKey, Number manValue) { + if (this.men$key == null) { + this.men$key = new java.util.ArrayList(); + this.men$value = new java.util.ArrayList(); + } + this.men$key.add(manKey); + this.men$value.add(manValue); + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder withMen(java.util.Map men) { + if (this.men$key == null) { + this.men$key = new java.util.ArrayList(); + this.men$value = new java.util.ArrayList(); + } + for (java.util.Map.Entry $lombokEntry : men.entrySet()) { + this.men$key.add($lombokEntry.getKey()); + this.men$value.add($lombokEntry.getValue()); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder clearMen() { + if (this.men$key != null) { + this.men$key.clear(); + this.men$value.clear(); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder withRawMan(Object rawMapKey, Object rawMapValue) { + if (this.rawMap$key == null) { + this.rawMap$key = new java.util.ArrayList(); + this.rawMap$value = new java.util.ArrayList(); + } + this.rawMap$key.add(rawMapKey); + this.rawMap$value.add(rawMapValue); + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder withRawMap(java.util.Map rawMap) { + if (this.rawMap$key == null) { + this.rawMap$key = new java.util.ArrayList(); + this.rawMap$value = new java.util.ArrayList(); + } + for (java.util.Map.Entry $lombokEntry : rawMap.entrySet()) { + this.rawMap$key.add($lombokEntry.getKey()); + this.rawMap$value.add($lombokEntry.getValue()); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder clearRawMap() { + if (this.rawMap$key != null) { + this.rawMap$key.clear(); + this.rawMap$value.clear(); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder stringMap(String stringMapKey, V stringMapValue) { + if (this.stringMap$key == null) { + this.stringMap$key = new java.util.ArrayList(); + this.stringMap$value = new java.util.ArrayList(); + } + this.stringMap$key.add(stringMapKey); + this.stringMap$value.add(stringMapValue); + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder stringMap(java.util.Map stringMap) { + if (this.stringMap$key == null) { + this.stringMap$key = new java.util.ArrayList(); + this.stringMap$value = new java.util.ArrayList(); + } + for (java.util.Map.Entry $lombokEntry : stringMap.entrySet()) { + this.stringMap$key.add($lombokEntry.getKey()); + this.stringMap$value.add($lombokEntry.getValue()); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsBuilder clearStringMap() { + if (this.stringMap$key != null) { + this.stringMap$key.clear(); + this.stringMap$value.clear(); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMaps build() { + java.util.Map women; + switch (this.women$key == null ? 0 : this.women$key.size()) { + case 0: + women = java.util.Collections.emptyMap(); + break; + case 1: + women = java.util.Collections.singletonMap(this.women$key.get(0), this.women$value.get(0)); + break; + default: + women = new java.util.LinkedHashMap(this.women$key.size() < 1073741824 ? 1 + this.women$key.size() + (this.women$key.size() - 3) / 3 : Integer.MAX_VALUE); + for (int $i = 0; $i < this.women$key.size(); $i++) women.put(this.women$key.get($i), (V) this.women$value.get($i)); + women = java.util.Collections.unmodifiableMap(women); + } + java.util.SortedMap men = new java.util.TreeMap(); + if (this.men$key != null) for (int $i = 0; $i < (this.men$key == null ? 0 : this.men$key.size()); $i++) men.put(this.men$key.get($i), (Number) this.men$value.get($i)); + men = java.util.Collections.unmodifiableSortedMap(men); + java.util.Map rawMap; + switch (this.rawMap$key == null ? 0 : this.rawMap$key.size()) { + case 0: + rawMap = java.util.Collections.emptyMap(); + break; + case 1: + rawMap = java.util.Collections.singletonMap(this.rawMap$key.get(0), this.rawMap$value.get(0)); + break; + default: + rawMap = new java.util.LinkedHashMap(this.rawMap$key.size() < 1073741824 ? 1 + this.rawMap$key.size() + (this.rawMap$key.size() - 3) / 3 : Integer.MAX_VALUE); + for (int $i = 0; $i < this.rawMap$key.size(); $i++) rawMap.put(this.rawMap$key.get($i), (Object) this.rawMap$value.get($i)); + rawMap = java.util.Collections.unmodifiableMap(rawMap); + } + java.util.Map stringMap; + switch (this.stringMap$key == null ? 0 : this.stringMap$key.size()) { + case 0: + stringMap = java.util.Collections.emptyMap(); + break; + case 1: + stringMap = java.util.Collections.singletonMap(this.stringMap$key.get(0), this.stringMap$value.get(0)); + break; + default: + stringMap = new java.util.LinkedHashMap(this.stringMap$key.size() < 1073741824 ? 1 + this.stringMap$key.size() + (this.stringMap$key.size() - 3) / 3 : Integer.MAX_VALUE); + for (int $i = 0; $i < this.stringMap$key.size(); $i++) stringMap.put(this.stringMap$key.get($i), (V) this.stringMap$value.get($i)); + stringMap = java.util.Collections.unmodifiableMap(stringMap); + } + return new BuilderSingularMaps(women, men, rawMap, stringMap); + } + @Override + @SuppressWarnings("all") + public String toString() { + return "BuilderSingularMaps.BuilderSingularMapsBuilder(women$key=" + this.women$key + ", women$value=" + this.women$value + ", men$key=" + this.men$key + ", men$value=" + this.men$value + ", rawMap$key=" + this.rawMap$key + ", rawMap$value=" + this.rawMap$value + ", stringMap$key=" + this.stringMap$key + ", stringMap$value=" + this.stringMap$value + ")"; + } + } + @SuppressWarnings("all") + public static BuilderSingularMapsBuilder builder() { + return new BuilderSingularMapsBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java new file mode 100644 index 00000000..453b9d74 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java @@ -0,0 +1,121 @@ +import java.util.List; +class BuilderSingularNoAuto { + private List things; + private List widgets; + private List items; + @java.lang.SuppressWarnings("all") + BuilderSingularNoAuto(final List things, final List widgets, final List items) { + this.things = things; + this.widgets = widgets; + this.items = items; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingularNoAutoBuilder { + @java.lang.SuppressWarnings("all") + private java.util.ArrayList things; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList widgets; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList items; + @java.lang.SuppressWarnings("all") + BuilderSingularNoAutoBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoBuilder withThings(final String things) { + if (this.things == null) this.things = new java.util.ArrayList(); + this.things.add(things); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoBuilder withThings(final java.util.Collection things) { + if (this.things == null) this.things = new java.util.ArrayList(); + this.things.addAll(things); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoBuilder clearThings() { + if (this.things != null) this.things.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoBuilder withWidget(final String widget) { + if (this.widgets == null) this.widgets = new java.util.ArrayList(); + this.widgets.add(widget); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoBuilder withWidgets(final java.util.Collection widgets) { + if (this.widgets == null) this.widgets = new java.util.ArrayList(); + this.widgets.addAll(widgets); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoBuilder clearWidgets() { + if (this.widgets != null) this.widgets.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoBuilder withItems(final String items) { + if (this.items == null) this.items = new java.util.ArrayList(); + this.items.add(items); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoBuilder withItems(final java.util.Collection items) { + if (this.items == null) this.items = new java.util.ArrayList(); + this.items.addAll(items); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoBuilder clearItems() { + if (this.items != null) this.items.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAuto build() { + java.util.List things; + switch (this.things == null ? 0 : this.things.size()) { + case 0: + things = java.util.Collections.emptyList(); + break; + case 1: + things = java.util.Collections.singletonList(this.things.get(0)); + break; + default: + things = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.things)); + } + java.util.List widgets; + switch (this.widgets == null ? 0 : this.widgets.size()) { + case 0: + widgets = java.util.Collections.emptyList(); + break; + case 1: + widgets = java.util.Collections.singletonList(this.widgets.get(0)); + break; + default: + widgets = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.widgets)); + } + java.util.List items; + switch (this.items == null ? 0 : this.items.size()) { + case 0: + items = java.util.Collections.emptyList(); + break; + case 1: + items = java.util.Collections.singletonList(this.items.get(0)); + break; + default: + items = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.items)); + } + return new BuilderSingularNoAuto(things, widgets, items); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularNoAuto.BuilderSingularNoAutoBuilder(things=" + this.things + ", widgets=" + this.widgets + ", items=" + this.items + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularNoAutoBuilder builder() { + return new BuilderSingularNoAutoBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularRedirectToGuavaWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularRedirectToGuavaWithSetterPrefix.java new file mode 100644 index 00000000..4b1b3d70 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularRedirectToGuavaWithSetterPrefix.java @@ -0,0 +1,93 @@ +import java.util.Set; +import java.util.NavigableMap; +import java.util.Collection; +class BuilderSingularRedirectToGuava { + private Set dangerMice; + private NavigableMap things; + private Collection> doohickeys; + @java.lang.SuppressWarnings("all") + BuilderSingularRedirectToGuava(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 BuilderSingularRedirectToGuavaBuilder { + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableSet.Builder dangerMice; + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableSortedMap.Builder things; + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableList.Builder> doohickeys; + @java.lang.SuppressWarnings("all") + BuilderSingularRedirectToGuavaBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularRedirectToGuavaBuilder withDangerMouse(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 BuilderSingularRedirectToGuavaBuilder withDangerMice(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 BuilderSingularRedirectToGuavaBuilder clearDangerMice() { + this.dangerMice = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularRedirectToGuavaBuilder withThing(final Integer key, final Number value) { + if (this.things == null) this.things = com.google.common.collect.ImmutableSortedMap.naturalOrder(); + this.things.put(key, value); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularRedirectToGuavaBuilder withThings(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 BuilderSingularRedirectToGuavaBuilder clearThings() { + this.things = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularRedirectToGuavaBuilder withDoohickey(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 BuilderSingularRedirectToGuavaBuilder withDoohickeys(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 BuilderSingularRedirectToGuavaBuilder clearDoohickeys() { + this.doohickeys = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularRedirectToGuava 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 BuilderSingularRedirectToGuava(dangerMice, things, doohickeys); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularRedirectToGuava.BuilderSingularRedirectToGuavaBuilder(dangerMice=" + this.dangerMice + ", things=" + this.things + ", doohickeys=" + this.doohickeys + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularRedirectToGuavaBuilder builder() { + return new BuilderSingularRedirectToGuavaBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularSetsWithPrefix.java b/test/transform/resource/after-delombok/BuilderSingularSetsWithPrefix.java new file mode 100644 index 00000000..e3817b59 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularSetsWithPrefix.java @@ -0,0 +1,153 @@ +import java.util.Set; +import java.util.SortedSet; +class BuilderSingularSets { + private Set dangerMice; + private SortedSet octopodes; + @SuppressWarnings("all") + private Set rawSet; + private Set stringSet; + @java.lang.SuppressWarnings("all") + BuilderSingularSets(final Set dangerMice, final SortedSet octopodes, final Set rawSet, final Set stringSet) { + this.dangerMice = dangerMice; + this.octopodes = octopodes; + this.rawSet = rawSet; + this.stringSet = stringSet; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingularSetsBuilder { + @java.lang.SuppressWarnings("all") + private java.util.ArrayList dangerMice; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList octopodes; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList rawSet; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList stringSet; + @java.lang.SuppressWarnings("all") + BuilderSingularSetsBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder withDangerMouse(final T dangerMouse) { + if (this.dangerMice == null) this.dangerMice = new java.util.ArrayList(); + this.dangerMice.add(dangerMouse); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder withDangerMice(final java.util.Collection dangerMice) { + if (this.dangerMice == null) this.dangerMice = new java.util.ArrayList(); + this.dangerMice.addAll(dangerMice); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder clearDangerMice() { + if (this.dangerMice != null) this.dangerMice.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder withOctopus(final Number octopus) { + if (this.octopodes == null) this.octopodes = new java.util.ArrayList(); + this.octopodes.add(octopus); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder withOctopodes(final java.util.Collection octopodes) { + if (this.octopodes == null) this.octopodes = new java.util.ArrayList(); + this.octopodes.addAll(octopodes); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder clearOctopodes() { + if (this.octopodes != null) this.octopodes.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder withRawSet(final java.lang.Object rawSet) { + if (this.rawSet == null) this.rawSet = new java.util.ArrayList(); + this.rawSet.add(rawSet); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder withRawSet(final java.util.Collection rawSet) { + if (this.rawSet == null) this.rawSet = new java.util.ArrayList(); + this.rawSet.addAll(rawSet); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder clearRawSet() { + if (this.rawSet != null) this.rawSet.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder withStringSet(final String stringSet) { + if (this.stringSet == null) this.stringSet = new java.util.ArrayList(); + this.stringSet.add(stringSet); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder withStringSet(final java.util.Collection stringSet) { + if (this.stringSet == null) this.stringSet = new java.util.ArrayList(); + this.stringSet.addAll(stringSet); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsBuilder clearStringSet() { + if (this.stringSet != null) this.stringSet.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSets build() { + java.util.Set dangerMice; + switch (this.dangerMice == null ? 0 : this.dangerMice.size()) { + case 0: + dangerMice = java.util.Collections.emptySet(); + break; + case 1: + dangerMice = java.util.Collections.singleton(this.dangerMice.get(0)); + break; + default: + dangerMice = new java.util.LinkedHashSet(this.dangerMice.size() < 1073741824 ? 1 + this.dangerMice.size() + (this.dangerMice.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); + dangerMice.addAll(this.dangerMice); + dangerMice = java.util.Collections.unmodifiableSet(dangerMice); + } + java.util.SortedSet octopodes = new java.util.TreeSet(); + if (this.octopodes != null) octopodes.addAll(this.octopodes); + octopodes = java.util.Collections.unmodifiableSortedSet(octopodes); + java.util.Set rawSet; + switch (this.rawSet == null ? 0 : this.rawSet.size()) { + case 0: + rawSet = java.util.Collections.emptySet(); + break; + case 1: + rawSet = java.util.Collections.singleton(this.rawSet.get(0)); + break; + default: + rawSet = new java.util.LinkedHashSet(this.rawSet.size() < 1073741824 ? 1 + this.rawSet.size() + (this.rawSet.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); + rawSet.addAll(this.rawSet); + rawSet = java.util.Collections.unmodifiableSet(rawSet); + } + java.util.Set stringSet; + switch (this.stringSet == null ? 0 : this.stringSet.size()) { + case 0: + stringSet = java.util.Collections.emptySet(); + break; + case 1: + stringSet = java.util.Collections.singleton(this.stringSet.get(0)); + break; + default: + stringSet = new java.util.LinkedHashSet(this.stringSet.size() < 1073741824 ? 1 + this.stringSet.size() + (this.stringSet.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); + stringSet.addAll(this.stringSet); + stringSet = java.util.Collections.unmodifiableSet(stringSet); + } + return new BuilderSingularSets(dangerMice, octopodes, rawSet, stringSet); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularSets.BuilderSingularSetsBuilder(dangerMice=" + this.dangerMice + ", octopodes=" + this.octopodes + ", rawSet=" + this.rawSet + ", stringSet=" + this.stringSet + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularSetsBuilder builder() { + return new BuilderSingularSetsBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularToBuilderWithNullWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularToBuilderWithNullWithSetterPrefix.java new file mode 100644 index 00000000..83e58e1d --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularToBuilderWithNullWithSetterPrefix.java @@ -0,0 +1,65 @@ +class BuilderSingularToBuilderWithNull { + private java.util.List elems; + public static void test() { + new BuilderSingularToBuilderWithNull(null).toBuilder(); + } + @java.lang.SuppressWarnings("all") + BuilderSingularToBuilderWithNull(final java.util.List elems) { + this.elems = elems; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingularToBuilderWithNullBuilder { + @java.lang.SuppressWarnings("all") + private java.util.ArrayList elems; + @java.lang.SuppressWarnings("all") + BuilderSingularToBuilderWithNullBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularToBuilderWithNullBuilder withElem(final String elem) { + if (this.elems == null) this.elems = new java.util.ArrayList(); + this.elems.add(elem); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularToBuilderWithNullBuilder withElems(final java.util.Collection elems) { + if (this.elems == null) this.elems = new java.util.ArrayList(); + this.elems.addAll(elems); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularToBuilderWithNullBuilder clearElems() { + if (this.elems != null) this.elems.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularToBuilderWithNull build() { + java.util.List elems; + switch (this.elems == null ? 0 : this.elems.size()) { + case 0: + elems = java.util.Collections.emptyList(); + break; + case 1: + elems = java.util.Collections.singletonList(this.elems.get(0)); + break; + default: + elems = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.elems)); + } + return new BuilderSingularToBuilderWithNull(elems); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java