aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java18
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java6
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java8
3 files changed, 23 insertions, 9 deletions
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
index fe5a6765..96a40090 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
@@ -125,10 +125,19 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
JCExpression thisDotFieldDotAddAll = chainDots(builderType, "this", data.getPluralName().toString(), getAddMethodName() + "All");
JCExpression invokeAddAll = maker.Apply(List.<JCExpression>nil(), thisDotFieldDotAddAll, List.<JCExpression>of(maker.Ident(data.getPluralName())));
statements.append(maker.Exec(invokeAddAll));
+
if (returnStatement != null) statements.append(returnStatement);
JCBlock body = maker.Block(0, statements.toList());
Name methodName = data.getPluralName();
if (!fluent) methodName = builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName() + "All", methodName.toString()));
+ JCExpression paramType = getPluralMethodParamType(builderType);
+ paramType = addTypeArgs(getTypeArgumentsCount(), true, builderType, paramType, data.getTypeArgs(), source);
+ long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
+ JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getPluralName(), paramType, null);
+ finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, methodName, List.of(param));
+ }
+
+ private JCExpression getPluralMethodParamType(JavacNode builderType) {
JCExpression paramType;
String aaTypeName = getAddAllTypeName();
if (aaTypeName.startsWith("java.lang.") && aaTypeName.indexOf('.', 11) == -1) {
@@ -136,12 +145,9 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
} else {
paramType = chainDotsString(builderType, aaTypeName);
}
- paramType = addTypeArgs(getTypeArgumentsCount(), true, builderType, paramType, data.getTypeArgs(), source);
- long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
- JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getPluralName(), paramType, null);
- finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, methodName, List.of(param));
- }
-
+ return paramType;
+ }
+
@Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
JavacTreeMaker maker = builderType.getTreeMaker();
List<JCExpression> jceBlank = List.nil();
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
index 95b29faf..e870142c 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
@@ -122,13 +122,17 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
JCBlock body = maker.Block(0, statements.toList());
Name name = data.getPluralName();
if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName("addAll", name.toString()));
- JCExpression paramType = chainDots(builderType, "java", "util", "Collection");
+ JCExpression paramType = getPluralMethodParamType(builderType);
paramType = addTypeArgs(1, true, builderType, paramType, data.getTypeArgs(), source);
long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getPluralName(), paramType, null);
finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, name, List.of(param));
}
+ private JCExpression getPluralMethodParamType(JavacNode builderType) {
+ return chainDots(builderType, "java", "util", "Collection");
+ }
+
@Override
protected String getAddMethodName() {
return "add";
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
index 610f041d..94938288 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
@@ -169,13 +169,17 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
JCBlock body = maker.Block(0, statements.toList());
Name name = data.getPluralName();
if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName("putAll", name.toString()));
- JCExpression paramType = chainDots(builderType, "java", "util", "Map");
+ JCExpression paramType = getPluralMethodParamType(builderType);
paramType = addTypeArgs(2, true, builderType, paramType, data.getTypeArgs(), source);
long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getPluralName(), paramType, null);
finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, name, List.of(param));
}
-
+
+ private JCExpression getPluralMethodParamType(JavacNode builderType) {
+ return chainDots(builderType, "java", "util", "Map");
+ }
+
@Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
if (useGuavaInstead(builderType)) {
guavaMapSingularizer.appendBuildCode(data, builderType, source, statements, targetVariableName, builderVariable);