mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 18:18:48 +00:00
Fix up some more tests and copy-paste errors
This commit is contained in:
1 parent
ffb299730e
commit
666defaff3
14 files changed
+51
-46
No files matched your search
@@ -539,7 +539,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
tps[i].name = typeArgsForToBuilder.get(i);
|
||||
}
|
||||
}
|
||||
MethodDeclaration md = generateToBuilderMethod(cfv, toBuilderMethodName, builderClassName, tdParent, tps, builderFields, fluent, ast, accessForOuters);
|
||||
MethodDeclaration md = generateToBuilderMethod(cfv, toBuilderMethodName, builderClassName, tdParent, tps, builderFields, fluent, ast, accessForOuters, builderInstance.setterPrefix());
|
||||
|
||||
if (md != null) injectMethod(tdParent, md);
|
||||
}
|
||||
@@ -552,7 +552,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
}
|
||||
|
||||
private static final char[] BUILDER_TEMP_VAR = {'b', 'u', 'i', 'l', 'd', 'e', 'r'};
|
||||
private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, String methodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, List<BuilderFieldData> builderFields, boolean fluent, ASTNode source, AccessLevel access) {
|
||||
private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, String methodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, List<BuilderFieldData> builderFields, boolean fluent, ASTNode source, AccessLevel access, String prefix) {
|
||||
int pS = source.sourceStart, pE = source.sourceEnd;
|
||||
long p = (long) pS << 32 | pE;
|
||||
|
||||
@@ -567,7 +567,14 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
Expression receiver = invoke;
|
||||
List<Statement> statements = null;
|
||||
for (BuilderFieldData bfd : builderFields) {
|
||||
char[] setterName = fluent ? bfd.name : HandlerUtil.buildAccessorName("set", new String(bfd.name)).toCharArray();
|
||||
String setterPrefix = prefix.isEmpty() ? "set" : prefix;
|
||||
//char[] setterName = fluent ? bfd.name : HandlerUtil.buildAccessorName("set", new String(bfd.name)).toCharArray();
|
||||
String setterName;
|
||||
if(fluent) {
|
||||
setterName = prefix.isEmpty() ? new String(bfd.name) : HandlerUtil.buildAccessorName(setterPrefix, new String(bfd.name));
|
||||
} else {
|
||||
setterName = HandlerUtil.buildAccessorName(setterPrefix, new String(bfd.name));
|
||||
}
|
||||
MessageSend ms = new MessageSend();
|
||||
Expression[] tgt = new Expression[bfd.singularData == null ? 1 : 2];
|
||||
|
||||
@@ -600,7 +607,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
}
|
||||
}
|
||||
|
||||
ms.selector = setterName;
|
||||
ms.selector = setterName.toCharArray();
|
||||
if (bfd.singularData == null) {
|
||||
ms.arguments = tgt;
|
||||
ms.receiver = receiver;
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
@Builder(toBuilder = true, setterPrefix = "with")
|
||||
class BuilderSingularWildcardListsWithToBuilderWithSetterPrefix {
|
||||
private List<?> objects;
|
||||
private Collection<? extends Number> numbers;
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ class BuilderWithExistingBuilderClassWithSetterPrefix<T, K extends Number> {
|
||||
public static <Z extends Number> BuilderWithExistingBuilderClassWithSetterPrefix<String, Z> staticMethod(Z arg1, boolean arg2, String arg3) {
|
||||
return null;
|
||||
}
|
||||
public static class BuilderWithExistingBuilderClassBuilderWithSetterPrefixBuilder<Z extends Number> {
|
||||
public static class BuilderWithExistingBuilderClassWithSetterPrefixBuilder<Z extends Number> {
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private boolean arg2;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
@@ -11,7 +11,7 @@ class BuilderWithExistingBuilderClassWithSetterPrefix<T, K extends Number> {
|
||||
public void withArg2(boolean arg) {
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
BuilderWithExistingBuilderClassBuilderWithSetterPrefixBuilder() {
|
||||
BuilderWithExistingBuilderClassWithSetterPrefixBuilder() {
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderWithExistingBuilderClassWithSetterPrefixBuilder<Z> withArg1(final Z arg1) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import lombok.Builder
|
||||
class BuilderWithNoBuilderMethodWithSetterPrefix {
|
||||
private String a = "";
|
||||
@java.lang.SuppressWarnings("all")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
class BuilderWithToBuilderWithSetterPrefix<T> {
|
||||
private String mOne;
|
||||
private String mTwo;
|
||||
|
||||
@@ -5,19 +5,19 @@ import java.util.List;
|
||||
@java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefixBuilder() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderWithPrefixBuilder<T> withUnprefixed(final int unprefixed) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefixBuilder<T> withUnprefixed(final int unprefixed) {
|
||||
this.unprefixed = unprefixed;
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderWithPrefix<T> build() {
|
||||
return new BuilderWithPrefix<T>(unprefixed);
|
||||
public @java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefix<T> build() {
|
||||
return new BuilderSimpleWithSetterPrefix<T>(unprefixed);
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
|
||||
return (("BuilderWithPrefix.BuilderWithPrefixBuilder(unprefixed=" + this.unprefixed) + ")");
|
||||
return (("BuilderSimpleWithSetterPrefix.BuilderSimpleWithSetterPrefixBuilder(unprefixed=" + this.unprefixed) + ")");
|
||||
}
|
||||
}
|
||||
private int unprefixed;
|
||||
@java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefixBuilder(final int unprefixed) {
|
||||
@java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefix(final int unprefixed) {
|
||||
super();
|
||||
this.unprefixed = unprefixed;
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import lombok.Singular;
|
||||
@java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> dangerMouse(final T dangerMouse) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> withDangerMouse(final T dangerMouse) {
|
||||
if ((this.dangerMice == null))
|
||||
this.dangerMice = new java.util.ArrayList<T>();
|
||||
this.dangerMice.add(dangerMouse);
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> dangerMice(final java.util.Collection<? extends T> dangerMice) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> withDangerMice(final java.util.Collection<? extends T> dangerMice) {
|
||||
if ((this.dangerMice == null))
|
||||
this.dangerMice = new java.util.ArrayList<T>();
|
||||
this.dangerMice.addAll(dangerMice);
|
||||
@@ -27,13 +27,13 @@ import lombok.Singular;
|
||||
this.dangerMice.clear();
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> octopus(final Number octopus) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> withOctopus(final Number octopus) {
|
||||
if ((this.octopodes == null))
|
||||
this.octopodes = new java.util.ArrayList<Number>();
|
||||
this.octopodes.add(octopus);
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> octopodes(final java.util.Collection<? extends Number> octopodes) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> withOctopodes(final java.util.Collection<? extends Number> octopodes) {
|
||||
if ((this.octopodes == null))
|
||||
this.octopodes = new java.util.ArrayList<Number>();
|
||||
this.octopodes.addAll(octopodes);
|
||||
@@ -44,13 +44,13 @@ import lombok.Singular;
|
||||
this.octopodes.clear();
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> rawSet(final java.lang.Object rawSet) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> withRawSet(final java.lang.Object rawSet) {
|
||||
if ((this.rawSet == null))
|
||||
this.rawSet = new java.util.ArrayList<java.lang.Object>();
|
||||
this.rawSet.add(rawSet);
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> rawSet(final java.util.Collection<?> rawSet) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> withRawSet(final java.util.Collection<?> rawSet) {
|
||||
if ((this.rawSet == null))
|
||||
this.rawSet = new java.util.ArrayList<java.lang.Object>();
|
||||
this.rawSet.addAll(rawSet);
|
||||
@@ -61,13 +61,13 @@ import lombok.Singular;
|
||||
this.rawSet.clear();
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> stringSet(final String stringSet) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> withStringSet(final String stringSet) {
|
||||
if ((this.stringSet == null))
|
||||
this.stringSet = new java.util.ArrayList<String>();
|
||||
this.stringSet.add(stringSet);
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> stringSet(final java.util.Collection<? extends String> stringSet) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder<T> withStringSet(final java.util.Collection<? extends String> stringSet) {
|
||||
if ((this.stringSet == null))
|
||||
this.stringSet = new java.util.ArrayList<String>();
|
||||
this.stringSet.addAll(stringSet);
|
||||
|
||||
@@ -22,7 +22,7 @@ import lombok.Singular;
|
||||
this.elems.clear();
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefixes build() {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefix build() {
|
||||
java.util.List<String> elems;
|
||||
switch (((this.elems == null) ? 0 : this.elems.size())) {
|
||||
case 0 :
|
||||
@@ -34,14 +34,14 @@ import lombok.Singular;
|
||||
default :
|
||||
elems = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(this.elems));
|
||||
}
|
||||
return new BuilderSingularWithPrefixesWithSetterPrefixes(elems);
|
||||
return new BuilderSingularWithPrefixesWithSetterPrefix(elems);
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
|
||||
return (("BuilderSingularWithPrefixesWithSetterPrefixes.BuilderSingularWithPrefixesWithSetterPrefixBuilder(elems=" + this.elems) + ")");
|
||||
return (("BuilderSingularWithPrefixesWithSetterPrefix.BuilderSingularWithPrefixesWithSetterPrefixBuilder(elems=" + this.elems) + ")");
|
||||
}
|
||||
}
|
||||
private @Singular java.util.List<String> _elems;
|
||||
@java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefixes(final java.util.List<String> elems) {
|
||||
@java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefix(final java.util.List<String> elems) {
|
||||
super();
|
||||
this._elems = elems;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import lombok.Builder;
|
||||
class BuilderWithExistingBuilderClassWithSetterPrefix<T, K extends Number> {
|
||||
public static class BuilderWithExistingBuilderClassBuilderWithSetterPrefixBuilder<Z extends Number> {
|
||||
public static class BuilderWithExistingBuilderClassWithSetterPrefixBuilder<Z extends Number> {
|
||||
private @java.lang.SuppressWarnings("all") boolean arg2;
|
||||
private @java.lang.SuppressWarnings("all") String arg3;
|
||||
private Z arg1;
|
||||
|
||||
@@ -4,7 +4,7 @@ import lombok.Value;
|
||||
public class BuilderWithRecursiveGenericsWithSetterPrefix {
|
||||
interface Inter<T, U extends Inter<T, U>> {
|
||||
}
|
||||
public static final @Builder(setterPrefix = "with(setterPrefix = "with")") @Value class Test<Foo, Bar extends Set<Foo>, Quz extends Inter<Bar, Quz>> {
|
||||
public static final @Builder(setterPrefix = "with") @Value class Test<Foo, Bar extends Set<Foo>, Quz extends Inter<Bar, Quz>> {
|
||||
public static @java.lang.SuppressWarnings("all") class TestBuilder<Foo, Bar extends Set<Foo>, Quz extends Inter<Bar, Quz>> {
|
||||
private @java.lang.SuppressWarnings("all") Foo foo;
|
||||
private @java.lang.SuppressWarnings("all") Bar bar;
|
||||
|
||||
@@ -80,44 +80,45 @@ import lombok.Builder;
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
@lombok.experimental.Accessors(prefix = "m") class ConstructorWithToBuilder<T> {
|
||||
public static @java.lang.SuppressWarnings("all") class ConstructorWithToBuilderBuilder<T> {
|
||||
|
||||
@lombok.experimental.Accessors(prefix = "m") class ConstructorWithToBuilderWithSetterPrefix<T> {
|
||||
public static @java.lang.SuppressWarnings("all") class ConstructorWithToBuilderWithSetterPrefixBuilder<T> {
|
||||
private @java.lang.SuppressWarnings("all") String mOne;
|
||||
private @java.lang.SuppressWarnings("all") T baz;
|
||||
private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableList<T> bars;
|
||||
@java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder() {
|
||||
@java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder<T> withMOne(final String mOne) {
|
||||
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder<T> withMOne(final String mOne) {
|
||||
this.mOne = mOne;
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder<T> withBaz(final T baz) {
|
||||
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder<T> withBaz(final T baz) {
|
||||
this.baz = baz;
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder<T> withBars(final com.google.common.collect.ImmutableList<T> bars) {
|
||||
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder<T> withBars(final com.google.common.collect.ImmutableList<T> bars) {
|
||||
this.bars = bars;
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilder<T> build() {
|
||||
return new ConstructorWithToBuilder<T>(mOne, baz, bars);
|
||||
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefix<T> build() {
|
||||
return new ConstructorWithToBuilderWithSetterPrefix<T>(mOne, baz, bars);
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
|
||||
return (((((("ConstructorWithToBuilder.ConstructorWithToBuilderBuilder(mOne=" + this.mOne) + ", baz=") + this.baz) + ", bars=") + this.bars) + ")");
|
||||
return (((((("ConstructorWithToBuilderWithSetterPrefix.ConstructorWithToBuilderWithSetterPrefixBuilder(mOne=" + this.mOne) + ", baz=") + this.baz) + ", bars=") + this.bars) + ")");
|
||||
}
|
||||
}
|
||||
private String mOne;
|
||||
private String mTwo;
|
||||
private T foo;
|
||||
private @lombok.Singular com.google.common.collect.ImmutableList<T> bars;
|
||||
public @Builder(toBuilder = true) ConstructorWithToBuilder(String mOne, @Builder.ObtainVia(field = "foo") T baz, com.google.common.collect.ImmutableList<T> bars) {
|
||||
public @Builder(toBuilder = true,setterPrefix = "with") ConstructorWithToBuilderWithSetterPrefix(String mOne, @Builder.ObtainVia(field = "foo") T baz, com.google.common.collect.ImmutableList<T> bars) {
|
||||
super();
|
||||
}
|
||||
public static @java.lang.SuppressWarnings("all") <T>ConstructorWithToBuilderBuilder<T> builder() {
|
||||
return new ConstructorWithToBuilderBuilder<T>();
|
||||
public static @java.lang.SuppressWarnings("all") <T>ConstructorWithToBuilderWithSetterPrefixBuilder<T> builder() {
|
||||
return new ConstructorWithToBuilderWithSetterPrefixBuilder<T>();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder<T> toBuilder() {
|
||||
return new ConstructorWithToBuilderBuilder<T>().withMOne(this.mOne).withBaz(this.foo).withBars(this.bars);
|
||||
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder<T> toBuilder() {
|
||||
return new ConstructorWithToBuilderWithSetterPrefixBuilder<T>().withMOne(this.mOne).withBaz(this.foo).withBars(this.bars);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import lombok.Builder
|
||||
import lombok.Builder;
|
||||
@Builder(toBuilder = true, builderMethodName = "",setterPrefix = "with")
|
||||
class BuilderWithNoBuilderMethodWithSetterPrefix {
|
||||
private String a = "";
|
||||
|
||||
@@ -5,7 +5,7 @@ class BuilderWithToBuilderWithSetterPrefix<T> {
|
||||
private String mOne, mTwo;
|
||||
@Builder.ObtainVia(method = "rrr", isStatic = true) private T foo;
|
||||
@lombok.Singular private List<T> bars;
|
||||
public static <K> K rrr(BuilderWithToBuilder<K> x) {
|
||||
public static <K> K rrr(BuilderWithToBuilderWithSetterPrefix<K> x) {
|
||||
return x.foo;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,6 @@ class ConstructorWithToBuilderWithSetterPrefix<T> {
|
||||
private T foo;
|
||||
@lombok.Singular private com.google.common.collect.ImmutableList<T> bars;
|
||||
@Builder(toBuilder = true, setterPrefix = "with")
|
||||
public ConstructorWithToBuilder(String mOne, @Builder.ObtainVia(field = "foo") T baz, com.google.common.collect.ImmutableList<T> bars) {
|
||||
public ConstructorWithToBuilderWithSetterPrefix(String mOne, @Builder.ObtainVia(field = "foo") T baz, com.google.common.collect.ImmutableList<T> bars) {
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class BuilderWithTolerateWithSetterPrefix {
|
||||
public static class BuilderWithTolerateWithSetterPrefixBuilder {
|
||||
@Tolerate
|
||||
public BuilderWithTolerateWithSetterPrefixBuilder withValue(String s) {
|
||||
return this.value(Integer.parseInt(s));
|
||||
return this.withValue(Integer.parseInt(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user