diff --git a/.gitignore b/.gitignore index b3f7b18d2e..824ae9c2b0 100644 --- a/.gitignore +++ b/.gitignore @@ -15,10 +15,11 @@ /.factorypath /lombok.iml /.idea +*.iml *.markdown.html /junit*.properties /eclipse.location /.apt_generated/ /out /website/lombokSupporters -/pom.xml \ No newline at end of file +/pom.xml diff --git a/AUTHORS b/AUTHORS index 91ef1793cd..77cbbfe92c 100755 --- a/AUTHORS +++ b/AUTHORS @@ -2,6 +2,7 @@ Lombok contributors in alphabetical order: Adam Juraszek Bulgakov Alexander +Caleb Brinkman Christian Nüssgens Christian Sterzl DaveLaw diff --git a/src/core/lombok/Builder.java b/src/core/lombok/Builder.java index dfa5ecb5f4..fcbe1a0962 100644 --- a/src/core/lombok/Builder.java +++ b/src/core/lombok/Builder.java @@ -153,6 +153,19 @@ * @return The builder class will be generated with this access modifier. */ AccessLevel access() default lombok.AccessLevel.PUBLIC; + + /** + * Prefix to prepend to set methods in the generated builder class. By default, generated methods to not include a + * prefix. If this value populated, the first letter of the generated method name will be capitalized. + * + * For example, a method normally generated as {@code someField(String someField)} would instead be generated as {@code withSomeField(String someField)} + * + * Note that using "with" to prefix builder setter methods is strongly discouraged as as "with" normally + * suggests immutable data structures, and builders by definition are mutable objects. + * + * @return The prefix to prepend to generated method names. + */ + String setterPrefix() default ""; /** * Put on a field (in case of {@code @Builder} on a type) or a parameter (for {@code @Builder} on a constructor or static method) to diff --git a/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java b/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java index da0bf47174..0f463ae249 100755 --- a/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java +++ b/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java @@ -120,6 +120,7 @@ public static final class SingularData { private final EclipseNode annotation; private final char[] singularName; private final char[] pluralName; + private final char[] setterPrefix; private final List typeArgs; private final String targetFqn; private final EclipseSingularizer singularizer; @@ -133,8 +134,20 @@ public SingularData(EclipseNode annotation, char[] singularName, char[] pluralNa this.targetFqn = targetFqn; this.singularizer = singularizer; this.source = source; + this.setterPrefix = new char[0]; } - + + public SingularData(EclipseNode annotation, char[] singularName, char[] pluralName, List typeArgs, String targetFqn, EclipseSingularizer singularizer, ASTNode source, char[] setterPrefix) { + this.annotation = annotation; + this.singularName = singularName; + this.pluralName = pluralName; + this.typeArgs = typeArgs; + this.targetFqn = targetFqn; + this.singularizer = singularizer; + this.source = source; + this.setterPrefix = setterPrefix; + } + public void setGeneratedByRecursive(ASTNode target) { SetGeneratedByVisitor visitor = new SetGeneratedByVisitor(source); @@ -162,7 +175,11 @@ public char[] getSingularName() { public char[] getPluralName() { return pluralName; } - + + public char[] getSetterPrefix() { + return setterPrefix; + } + public List getTypeArgs() { return typeArgs; } diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java index 8bfdeb65eb..aab97e18c7 100755 --- a/src/core/lombok/eclipse/handlers/HandleBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java @@ -1,16 +1,16 @@ /* * Copyright (C) 2013-2019 The Project Lombok Authors. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -101,17 +101,17 @@ @HandlerPriority(-1024) //-2^10; to ensure we've picked up @FieldDefault's changes (-2048) but @Value hasn't removed itself yet (-512), so that we can error on presence of it on the builder classes. public class HandleBuilder extends EclipseAnnotationHandler { private HandleConstructor handleConstructor = new HandleConstructor(); - + private static final char[] CLEAN_FIELD_NAME = "$lombokUnclean".toCharArray(); private static final char[] CLEAN_METHOD_NAME = "$lombokClean".toCharArray(); - + private static final boolean toBoolean(Object expr, boolean defaultValue) { if (expr == null) return defaultValue; if (expr instanceof FalseLiteral) return false; if (expr instanceof TrueLiteral) return true; return ((Boolean) expr).booleanValue(); } - + static class BuilderFieldData { Annotation[] annotations; TypeReference type; @@ -124,10 +124,10 @@ static class BuilderFieldData { ObtainVia obtainVia; EclipseNode obtainViaNode; EclipseNode originalFieldNode; - + List createdFields = new ArrayList(); } - + private static boolean equals(String a, char[] b) { if (a.length() != b.length) return false; for (int i = 0; i < b.length; i++) { @@ -135,7 +135,7 @@ private static boolean equals(String a, char[] b) { } return true; } - + private static boolean equals(String a, char[][] b) { if (a == null || a.isEmpty()) return b.length == 0; String[] aParts = a.split("\\."); @@ -145,24 +145,24 @@ private static boolean equals(String a, char[][] b) { } return true; } - + private static final char[] DEFAULT_PREFIX = {'$', 'd', 'e', 'f', 'a', 'u', 'l', 't', '$'}; private static final char[] SET_PREFIX = {'$', 's', 'e', 't'}; private static final char[] VALUE_PREFIX = {'$', 'v', 'a', 'l', 'u', 'e'}; - + private static final char[] prefixWith(char[] prefix, char[] name) { char[] out = new char[prefix.length + name.length]; System.arraycopy(prefix, 0, out, 0, prefix.length); System.arraycopy(name, 0, out, prefix.length, name.length); return out; } - + @Override public void handle(AnnotationValues annotation, Annotation ast, EclipseNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.BUILDER_FLAG_USAGE, "@Builder"); CheckerFrameworkVersion cfv = getCheckerFrameworkVersion(annotationNode); - + long p = (long) ast.sourceStart << 32 | ast.sourceEnd; - + Builder builderInstance = annotation.getInstance(); AccessLevel accessForOuters = builderInstance.access(); if (accessForOuters == null) accessForOuters = AccessLevel.PUBLIC; @@ -171,22 +171,22 @@ private static final char[] prefixWith(char[] prefix, char[] name) { accessForOuters = AccessLevel.PUBLIC; } AccessLevel accessForInners = accessForOuters == AccessLevel.PROTECTED ? AccessLevel.PUBLIC : accessForOuters; - + // These exist just to support the 'old' lombok.experimental.Builder, which had these properties. lombok.Builder no longer has them. boolean fluent = toBoolean(annotation.getActualExpression("fluent"), true); boolean chain = toBoolean(annotation.getActualExpression("chain"), true); - + String builderMethodName = builderInstance.builderMethodName(); String buildMethodName = builderInstance.buildMethodName(); String builderClassName = builderInstance.builderClassName(); String toBuilderMethodName = "toBuilder"; boolean toBuilder = builderInstance.toBuilder(); List typeArgsForToBuilder = null; - + if (builderMethodName == null) builderMethodName = "builder"; if (buildMethodName == null) buildMethodName = "build"; if (builderClassName == null) builderClassName = ""; - + boolean generateBuilderMethod; if (builderMethodName.isEmpty()) { generateBuilderMethod = false; @@ -195,74 +195,74 @@ private static final char[] prefixWith(char[] prefix, char[] name) { } else { generateBuilderMethod = true; } - + if (!checkName("buildMethodName", buildMethodName, annotationNode)) return; if (!builderClassName.isEmpty()) { if (!checkName("builderClassName", builderClassName, annotationNode)) return; } - + EclipseNode parent = annotationNode.up(); - + List builderFields = new ArrayList(); TypeReference returnType; TypeParameter[] typeParams; TypeReference[] thrownExceptions; char[] nameOfStaticBuilderMethod; EclipseNode tdParent; - + EclipseNode fillParametersFrom = parent.get() instanceof AbstractMethodDeclaration ? parent : null; boolean addCleaning = false; boolean isStatic = true; - + List nonFinalNonDefaultedFields = null; - + if (builderClassName.isEmpty()) builderClassName = annotationNode.getAst().readConfiguration(ConfigurationKeys.BUILDER_CLASS_NAME); if (builderClassName == null || builderClassName.isEmpty()) builderClassName = "*Builder"; boolean replaceNameInBuilderClassName = builderClassName.contains("*"); - + if (parent.get() instanceof TypeDeclaration) { tdParent = parent; TypeDeclaration td = (TypeDeclaration) tdParent.get(); - + List allFields = new ArrayList(); boolean valuePresent = (hasAnnotation(lombok.Value.class, parent) || hasAnnotation("lombok.experimental.Value", parent)); for (EclipseNode fieldNode : HandleConstructor.findAllFields(tdParent, true)) { FieldDeclaration fd = (FieldDeclaration) fieldNode.get(); EclipseNode isDefault = findAnnotation(Builder.Default.class, fieldNode); boolean isFinal = ((fd.modifiers & ClassFileConstants.AccFinal) != 0) || (valuePresent && !hasAnnotation(NonFinal.class, fieldNode)); - + Annotation[] copyableAnnotations = findCopyableAnnotations(fieldNode); - + BuilderFieldData bfd = new BuilderFieldData(); bfd.rawName = fieldNode.getName().toCharArray(); bfd.name = removePrefixFromField(fieldNode); bfd.builderFieldName = bfd.name; bfd.annotations = copyAnnotations(fd, copyableAnnotations); bfd.type = fd.type; - bfd.singularData = getSingularData(fieldNode, ast); + bfd.singularData = getSingularData(fieldNode, ast, builderInstance.setterPrefix()); bfd.originalFieldNode = fieldNode; - + if (bfd.singularData != null && isDefault != null) { isDefault.addError("@Builder.Default and @Singular cannot be mixed."); isDefault = null; } - + if (fd.initialization == null && isDefault != null) { isDefault.addWarning("@Builder.Default requires an initializing expression (' = something;')."); isDefault = null; } - + if (fd.initialization != null && isDefault == null) { if (isFinal) continue; if (nonFinalNonDefaultedFields == null) nonFinalNonDefaultedFields = new ArrayList(); nonFinalNonDefaultedFields.add(fieldNode); } - + if (isDefault != null) { bfd.nameOfDefaultProvider = prefixWith(DEFAULT_PREFIX, bfd.name); bfd.nameOfSetFlag = prefixWith(bfd.name, SET_PREFIX); bfd.builderFieldName = prefixWith(bfd.name, VALUE_PREFIX); - + MethodDeclaration md = generateDefaultProvider(bfd.nameOfDefaultProvider, td.typeParameters, fieldNode, ast); if (md != null) injectMethod(tdParent, md); } @@ -270,10 +270,10 @@ private static final char[] prefixWith(char[] prefix, char[] name) { builderFields.add(bfd); allFields.add(fieldNode); } - + handleConstructor.generateConstructor(tdParent, AccessLevel.PACKAGE, allFields, false, null, SkipIfConstructorExists.I_AM_BUILDER, Collections.emptyList(), annotationNode); - + returnType = namePlusTypeParamsToTypeReference(td.name, td.typeParameters, p); typeParams = td.typeParameters; thrownExceptions = null; @@ -286,7 +286,7 @@ private static final char[] prefixWith(char[] prefix, char[] name) { annotationNode.addError("@Builder is not supported on constructors with constructor type parameters."); return; } - + tdParent = parent.up(); TypeDeclaration td = (TypeDeclaration) tdParent.get(); returnType = namePlusTypeParamsToTypeReference(td.name, td.typeParameters, p); @@ -299,7 +299,7 @@ private static final char[] prefixWith(char[] prefix, char[] name) { MethodDeclaration md = (MethodDeclaration) parent.get(); tdParent = parent.up(); isStatic = md.isStatic(); - + if (toBuilder) { final String TO_BUILDER_NOT_SUPPORTED = "@Builder(toBuilder=true) is only supported if you return your own type."; char[] token; @@ -308,7 +308,7 @@ private static final char[] prefixWith(char[] prefix, char[] name) { annotationNode.addError(TO_BUILDER_NOT_SUPPORTED); return; } - + if (md.returnType instanceof SingleTypeReference) { token = ((SingleTypeReference) md.returnType).token; } else if (md.returnType instanceof QualifiedTypeReference) { @@ -321,17 +321,17 @@ private static final char[] prefixWith(char[] prefix, char[] name) { annotationNode.addError(TO_BUILDER_NOT_SUPPORTED); return; } - + if (pkg != null && !equals(parent.getPackageDeclaration(), pkg)) { annotationNode.addError(TO_BUILDER_NOT_SUPPORTED); return; } - + if (tdParent == null || !equals(tdParent.getName(), token)) { annotationNode.addError(TO_BUILDER_NOT_SUPPORTED); return; } - + TypeParameter[] tpOnType = ((TypeDeclaration) tdParent.get()).typeParameters; TypeParameter[] tpOnMethod = md.typeParameters; TypeReference[][] tpOnRet_ = null; @@ -341,7 +341,7 @@ private static final char[] prefixWith(char[] prefix, char[] name) { } else if (md.returnType instanceof ParameterizedQualifiedTypeReference) { tpOnRet_ = ((ParameterizedQualifiedTypeReference) md.returnType).typeArguments; } - + if (tpOnRet_ != null) for (int i = 0; i < tpOnRet_.length - 1; i++) { if (tpOnRet_[i] != null && tpOnRet_[i].length > 0) { annotationNode.addError("@Builder(toBuilder=true) is not supported if returning a type with generics applied to an intermediate."); @@ -350,11 +350,11 @@ private static final char[] prefixWith(char[] prefix, char[] name) { } TypeReference[] tpOnRet = tpOnRet_ == null ? null : tpOnRet_[tpOnRet_.length - 1]; typeArgsForToBuilder = new ArrayList(); - + // Every typearg on this method needs to be found in the return type, but the reverse is not true. // We also need to 'map' them. - - + + if (tpOnMethod != null) for (TypeParameter onMethod : tpOnMethod) { int pos = -1; if (tpOnRet != null) for (int i = 0; i < tpOnRet.length; i++) { @@ -366,11 +366,11 @@ private static final char[] prefixWith(char[] prefix, char[] name) { annotationNode.addError("@Builder(toBuilder=true) requires that each type parameter on the static method is part of the typeargs of the return value. Type parameter " + new String(onMethod.name) + " is not part of the return type."); return; } - + typeArgsForToBuilder.add(tpOnType[pos].name); } } - + returnType = copyType(md.returnType, ast); typeParams = md.typeParameters; thrownExceptions = md.thrownExceptions; @@ -394,41 +394,41 @@ private static final char[] prefixWith(char[] prefix, char[] name) { annotationNode.addError("Unexpected kind of return type on annotated method. Specify 'builderClassName' to solve this problem."); return; } - + if (Character.isLowerCase(token[0])) { char[] newToken = new char[token.length]; System.arraycopy(token, 1, newToken, 1, token.length - 1); newToken[0] = Character.toTitleCase(token[0]); token = newToken; } - + builderClassName = builderClassName.replace("*", new String(token)); } } else { annotationNode.addError("@Builder is only supported on types, constructors, and methods."); return; } - + if (fillParametersFrom != null) { for (EclipseNode param : fillParametersFrom.down()) { if (param.getKind() != Kind.ARGUMENT) continue; BuilderFieldData bfd = new BuilderFieldData(); Argument arg = (Argument) param.get(); - + Annotation[] copyableAnnotations = findCopyableAnnotations(param); - + bfd.rawName = arg.name; bfd.name = arg.name; bfd.builderFieldName = bfd.name; bfd.annotations = copyAnnotations(arg, copyableAnnotations); bfd.type = arg.type; - bfd.singularData = getSingularData(param, ast); + bfd.singularData = getSingularData(param, ast, builderInstance.setterPrefix()); bfd.originalFieldNode = param; addObtainVia(bfd, param); builderFields.add(bfd); } } - + EclipseNode builderType = findInnerClass(tdParent, builderClassName); if (builderType == null) { builderType = makeBuilderClass(isStatic, tdParent, builderClassName, typeParams, ast, accessForOuters); @@ -454,7 +454,7 @@ private static final char[] prefixWith(char[] prefix, char[] name) { } } } - + for (BuilderFieldData bfd : builderFields) { if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) { if (bfd.singularData.getSingularizer().requiresCleaning()) { @@ -473,7 +473,7 @@ private static final char[] prefixWith(char[] prefix, char[] name) { } } } - + generateBuilderFields(builderType, builderFields, ast); if (addCleaning) { FieldDeclaration cleanDecl = new FieldDeclaration(CLEAN_FIELD_NAME, 0, -1); @@ -483,18 +483,18 @@ private static final char[] prefixWith(char[] prefix, char[] name) { cleanDecl.traverse(new SetGeneratedByVisitor(ast), (MethodScope) null); injectFieldAndMarkGenerated(builderType, cleanDecl); } - + if (constructorExists(builderType) == MemberExistsResult.NOT_EXISTS) { ConstructorDeclaration cd = HandleConstructor.createConstructor( AccessLevel.PACKAGE, builderType, Collections.emptyList(), false, annotationNode, Collections.emptyList()); if (cd != null) injectMethod(builderType, cd); } - + for (BuilderFieldData bfd : builderFields) { - makeSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, fluent, chain, accessForInners, bfd.originalFieldNode); + makePrefixedSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, fluent, chain, accessForInners, bfd.originalFieldNode, builderInstance.setterPrefix()); } - + { MemberExistsResult methodExists = methodExists(buildMethodName, builderType, -1); if (methodExists == MemberExistsResult.EXISTS_BY_LOMBOK) methodExists = methodExists(buildMethodName, builderType, 0); @@ -503,7 +503,7 @@ private static final char[] prefixWith(char[] prefix, char[] name) { if (md != null) injectMethod(builderType, md); } } - + if (methodExists("toString", builderType, 0) == MemberExistsResult.NOT_EXISTS) { List> fieldNodes = new ArrayList>(); for (BuilderFieldData bfd : builderFields) { @@ -514,18 +514,18 @@ private static final char[] prefixWith(char[] prefix, char[] name) { MethodDeclaration md = HandleToString.createToString(builderType, fieldNodes, true, false, ast, FieldAccess.ALWAYS_FIELD); if (md != null) injectMethod(builderType, md); } - + if (addCleaning) { MethodDeclaration cleanMethod = generateCleanMethod(builderFields, builderType, ast); if (cleanMethod != null) injectMethod(builderType, cleanMethod); } - + if (generateBuilderMethod && methodExists(builderMethodName, tdParent, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false; if (generateBuilderMethod) { MethodDeclaration md = generateBuilderMethod(cfv, isStatic, builderMethodName, builderClassName, tdParent, typeParams, ast, accessForOuters); if (md != null) injectMethod(tdParent, md); } - + if (toBuilder) switch (methodExists(toBuilderMethodName, tdParent, 0)) { case EXISTS_BY_USER: annotationNode.addWarning("Not generating toBuilder() as it already exists."); @@ -539,23 +539,23 @@ private static final char[] prefixWith(char[] prefix, char[] name) { 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); } - + if (nonFinalNonDefaultedFields != null && generateBuilderMethod) { for (EclipseNode fieldNode : nonFinalNonDefaultedFields) { fieldNode.addWarning("@Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. If it is not supposed to be settable during building, make the field final."); } } } - + 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 builderFields, boolean fluent, ASTNode source, AccessLevel access) { + private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, String methodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, List builderFields, boolean fluent, ASTNode source, AccessLevel access, String prefix) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long) pS << 32 | pE; - + MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult); out.selector = methodName.toCharArray(); out.modifiers = toEclipseModifier(access); @@ -563,14 +563,20 @@ private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, S out.returnType = namePlusTypeParamsToTypeReference(builderClassName.toCharArray(), typeParams, p); AllocationExpression invoke = new AllocationExpression(); invoke.type = namePlusTypeParamsToTypeReference(builderClassName.toCharArray(), typeParams, p); - + Expression receiver = invoke; List 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; + 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]; - + if (bfd.obtainVia == null || !bfd.obtainVia.field().isEmpty()) { char[] fieldName = bfd.obtainVia == null ? bfd.rawName : bfd.obtainVia.field().toCharArray(); for (int i = 0; i < tgt.length; i++) { @@ -599,8 +605,8 @@ private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, S tgt[i] = obtainExpr; } } - - ms.selector = setterName; + + ms.selector = setterName.toCharArray(); if (bfd.singularData == null) { ms.arguments = tgt; ms.receiver = receiver; @@ -613,7 +619,7 @@ private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, S statements.add(new IfStatement(isNotNull, ms, pS, pE)); } } - + if (statements != null) { out.statements = new Statement[statements.size() + 2]; for (int i = 0; i < statements.size(); i++) out.statements[i + 1] = statements.get(i); @@ -627,25 +633,25 @@ private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, S } else { out.statements = new Statement[] {new ReturnStatement(receiver, pS, pE)}; } - + if (cfv.generateUnique()) { out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)}; } - + out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope); return out; } - + private MethodDeclaration generateCleanMethod(List builderFields, EclipseNode builderType, ASTNode source) { List statements = new ArrayList(); - + for (BuilderFieldData bfd : builderFields) { if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) { bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, builderType, statements); } } - + FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0); thisUnclean.receiver = new ThisReference(0, 0); statements.add(new Assignment(thisUnclean, new FalseLiteral(0, 0), 0)); @@ -658,15 +664,15 @@ private MethodDeclaration generateCleanMethod(List builderFiel decl.traverse(new SetGeneratedByVisitor(source), (ClassScope) null); return decl; } - + static Argument[] generateBuildArgs(CheckerFrameworkVersion cfv, EclipseNode type, List builderFields, ASTNode source) { if (!cfv.generateCalledMethods()) return null; - + List mandatories = new ArrayList(); for (BuilderFieldData bfd : builderFields) { if (bfd.singularData == null && bfd.nameOfSetFlag == null) mandatories.add(bfd.name); } - + if (mandatories.size() == 0) return null; char[][] nameCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__CALLED); SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameCalled, poss(source, nameCalled.length)), source.sourceStart); @@ -686,12 +692,12 @@ static Argument[] generateBuildArgs(CheckerFrameworkVersion cfv, EclipseNode typ arg.annotations = new Annotation[] {ann}; return new Argument[] {arg}; } - + public MethodDeclaration generateBuildMethod(CheckerFrameworkVersion cfv, EclipseNode tdParent, boolean isStatic, String name, char[] staticName, TypeReference returnType, List builderFields, EclipseNode type, TypeReference[] thrownExceptions, boolean addCleaning, ASTNode source, AccessLevel access) { MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult); out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; List statements = new ArrayList(); - + if (addCleaning) { FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0); thisUnclean.receiver = new ThisReference(0, 0); @@ -700,13 +706,13 @@ public MethodDeclaration generateBuildMethod(CheckerFrameworkVersion cfv, Eclips invokeClean.selector = CLEAN_METHOD_NAME; statements.add(new IfStatement(notClean, invokeClean, 0, 0)); } - + for (BuilderFieldData bfd : builderFields) { if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) { bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, type, statements, bfd.builderFieldName, "this"); } } - + List args = new ArrayList(); for (BuilderFieldData bfd : builderFields) { if (bfd.nameOfSetFlag != null) { @@ -716,7 +722,7 @@ public MethodDeclaration generateBuildMethod(CheckerFrameworkVersion cfv, Eclips inv.receiver = new SingleNameReference(((TypeDeclaration) tdParent.get()).name, 0L); inv.selector = bfd.nameOfDefaultProvider; inv.typeArguments = typeParameterNames(((TypeDeclaration) type.get()).typeParameters); - + args.add(new ConditionalExpression( new SingleNameReference(bfd.nameOfSetFlag, 0L), new SingleNameReference(bfd.builderFieldName, 0L), @@ -725,19 +731,19 @@ public MethodDeclaration generateBuildMethod(CheckerFrameworkVersion cfv, Eclips args.add(new SingleNameReference(bfd.builderFieldName, 0L)); } } - + if (addCleaning) { FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0); thisUnclean.receiver = new ThisReference(0, 0); statements.add(new Assignment(thisUnclean, new TrueLiteral(0, 0), 0)); } - + out.modifiers = toEclipseModifier(access); out.selector = name.toCharArray(); out.thrownExceptions = copyTypes(thrownExceptions); out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; out.returnType = returnType; - + if (staticName == null) { AllocationExpression allocationStatement = new AllocationExpression(); allocationStatement.type = copyType(out.returnType); @@ -750,7 +756,7 @@ public MethodDeclaration generateBuildMethod(CheckerFrameworkVersion cfv, Eclips invoke.receiver = new SingleNameReference(type.up().getName().toCharArray(), 0); else invoke.receiver = new QualifiedThisReference(new SingleTypeReference(type.up().getName().toCharArray(), 0) , 0, 0); - + invoke.typeArguments = typeParameterNames(((TypeDeclaration) type.get()).typeParameters); invoke.arguments = args.isEmpty() ? null : args.toArray(new Expression[0]); if (returnType instanceof SingleTypeReference && Arrays.equals(TypeConstants.VOID, ((SingleTypeReference) returnType).token)) { @@ -767,20 +773,20 @@ public MethodDeclaration generateBuildMethod(CheckerFrameworkVersion cfv, Eclips out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null); return out; } - + private TypeReference[] typeParameterNames(TypeParameter[] typeParameters) { if (typeParameters == null) return null; - + TypeReference[] trs = new TypeReference[typeParameters.length]; for (int i = 0; i < trs.length; i++) { trs[i] = new SingleTypeReference(typeParameters[i].name, 0); } return trs; } - + public static MethodDeclaration generateDefaultProvider(char[] methodName, TypeParameter[] typeParameters, EclipseNode fieldNode, ASTNode source) { int pS = source.sourceStart, pE = source.sourceEnd; - + MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) fieldNode.top().get()).compilationResult); out.typeParameters = copyTypeParams(typeParameters, source); out.selector = methodName; @@ -790,15 +796,15 @@ public static MethodDeclaration generateDefaultProvider(char[] methodName, TypeP out.returnType = copyType(fd.type, source); out.statements = new Statement[] {new ReturnStatement(fd.initialization, pS, pE)}; fd.initialization = null; - + out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) fieldNode.up().get()).scope); return out; } - + public MethodDeclaration generateBuilderMethod(CheckerFrameworkVersion cfv, boolean isStatic, String builderMethodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source, AccessLevel access) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long) pS << 32 | pE; - + MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult); out.selector = builderMethodName.toCharArray(); out.modifiers = toEclipseModifier(access); @@ -821,13 +827,13 @@ public MethodDeclaration generateBuilderMethod(CheckerFrameworkVersion cfv, bool out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope); return out; } - + public void generateBuilderFields(EclipseNode builderType, List builderFields, ASTNode source) { List existing = new ArrayList(); for (EclipseNode child : builderType.down()) { if (child.getKind() == Kind.FIELD) existing.add(child); } - + for (BuilderFieldData bfd : builderFields) { if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) { bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType)); @@ -838,7 +844,7 @@ public void generateBuilderFields(EclipseNode builderType, List methodAnnsList = Arrays.asList(EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode)); + Annotation[] methodAnns = EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode); + if (methodAnns != null && methodAnns.length > 0) methodAnnsList = Arrays.asList(methodAnns); + MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, paramName, nameOfSetFlag, chain, toEclipseModifier(access), + sourceNode, methodAnnsList, annotations != null ? Arrays.asList(copyAnnotations(sourceNode.get(), annotations)) : Collections.emptyList()); + if (cfv.generateCalledMethods()) { + Argument[] arr = setter.arguments == null ? new Argument[0] : setter.arguments; + Argument[] newArr = new Argument[arr.length + 1]; + System.arraycopy(arr, 0, newArr, 1, arr.length); + newArr[0] = new Argument(new char[] { 't', 'h', 'i', 's' }, 0, new SingleTypeReference(builderType.getName().toCharArray(), 0), Modifier.FINAL); + char[][] nameNotCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__NOT_CALLED); + SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss(source, nameNotCalled.length)), source.sourceStart); + ann.memberValue = new StringLiteral(setterName.toCharArray(), 0, 0, 0); + newArr[0].annotations = new Annotation[] {ann}; + setter.arguments = newArr; + } + injectMethod(builderType, setter); + } + + public void makePrefixedSetterMethodsForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, boolean fluent, boolean chain, AccessLevel access, EclipseNode originalFieldNode, String prefix) { + boolean deprecate = isFieldDeprecated(bfd.originalFieldNode); + if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) { + makePrefixedSetterMethodForBuilder(cfv, builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, sourceNode, fluent, chain, bfd.annotations, access, originalFieldNode, prefix); + } else { + bfd.singularData.getSingularizer().generateMethods(cfv, bfd.singularData, deprecate, builderType, fluent, chain, access); + } + } + + private void makePrefixedSetterMethodForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, EclipseNode sourceNode, boolean fluent, boolean chain, Annotation[] annotations, AccessLevel access, EclipseNode originalFieldNode, String prefix) { + TypeDeclaration td = (TypeDeclaration) builderType.get(); + AbstractMethodDeclaration[] existing = td.methods; + if (existing == null) existing = EMPTY; + int len = existing.length; + + String setterPrefix = prefix.isEmpty() ? "set" : prefix; + String setterName; + if(fluent) { + setterName = prefix.isEmpty() ? new String(paramName) : HandlerUtil.buildAccessorName(setterPrefix, new String(paramName)); + } else { + setterName = HandlerUtil.buildAccessorName(setterPrefix, new String(paramName)); + } + + for (int i = 0; i < len; i++) { + if (!(existing[i] instanceof MethodDeclaration)) continue; + char[] existingName = existing[i].selector; + if (Arrays.equals(setterName.toCharArray(), existingName) && !isTolerate(fieldNode, existing[i])) return; + } + + List methodAnnsList = Collections.emptyList(); + Annotation[] methodAnns = EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode); + if (methodAnns != null && methodAnns.length > 0) methodAnnsList = Arrays.asList(methodAnns); + ASTNode source = sourceNode.get(); MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, paramName, nameOfSetFlag, chain, toEclipseModifier(access), sourceNode, methodAnnsList, annotations != null ? Arrays.asList(copyAnnotations(source, annotations)) : Collections.emptyList()); if (cfv.generateCalledMethods()) { @@ -897,14 +954,15 @@ private void makeSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, Eclip System.arraycopy(arr, 0, newArr, 1, arr.length); newArr[0] = new Argument(new char[] { 't', 'h', 'i', 's' }, 0, new SingleTypeReference(builderType.getName().toCharArray(), 0), Modifier.FINAL); char[][] nameNotCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__NOT_CALLED); - SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss(source, nameNotCalled.length)), source.sourceStart); + SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss( + source, nameNotCalled.length)), source.sourceStart); ann.memberValue = new StringLiteral(setterName.toCharArray(), 0, 0, 0); newArr[0].annotations = new Annotation[] {ann}; setter.arguments = newArr; } injectMethod(builderType, setter); } - + public EclipseNode makeBuilderClass(boolean isStatic, EclipseNode tdParent, String builderClassName, TypeParameter[] typeParams, ASTNode source, AccessLevel access) { TypeDeclaration parent = (TypeDeclaration) tdParent.get(); TypeDeclaration builder = new TypeDeclaration(parent.compilationResult); @@ -916,7 +974,7 @@ public EclipseNode makeBuilderClass(boolean isStatic, EclipseNode tdParent, Stri builder.traverse(new SetGeneratedByVisitor(source), (ClassScope) null); return injectType(tdParent, builder); } - + private void addObtainVia(BuilderFieldData bfd, EclipseNode node) { for (EclipseNode child : node.down()) { if (!annotationTypeMatches(ObtainVia.class, child)) continue; @@ -926,14 +984,15 @@ private void addObtainVia(BuilderFieldData bfd, EclipseNode node) { return; } } - + /** * Returns the explicitly requested singular annotation on this node (field * or parameter), or null if there's no {@code @Singular} annotation on it. - * + * * @param node The node (field or method param) to inspect for its name and potential {@code @Singular} annotation. + * @param setterPrefix */ - private SingularData getSingularData(EclipseNode node, ASTNode source) { + private SingularData getSingularData(EclipseNode node, ASTNode source, final String setterPrefix) { for (EclipseNode child : node.down()) { if (!annotationTypeMatches(Singular.class, child)) continue; char[] pluralName = node.getKind() == Kind.FIELD ? removePrefixFromField(node) : ((AbstractVariableDeclaration) node.get()).name; @@ -952,7 +1011,7 @@ private SingularData getSingularData(EclipseNode node, ASTNode source) { } } char[] singularName = explicitSingular.toCharArray(); - + TypeReference type = ((AbstractVariableDeclaration) node.get()).type; TypeReference[] typeArgs = null; String typeName; @@ -972,7 +1031,7 @@ private SingularData getSingularData(EclipseNode node, ASTNode source) { } else { typeName = type.toString(); } - + String targetFqn = EclipseSingularsRecipes.get().toQualified(typeName); EclipseSingularizer singularizer = EclipseSingularsRecipes.get().getSingularizer(targetFqn); if (singularizer == null) { @@ -980,9 +1039,9 @@ private SingularData getSingularData(EclipseNode node, ASTNode source) { return null; } - return new SingularData(child, singularName, pluralName, typeArgs == null ? Collections.emptyList() : Arrays.asList(typeArgs), targetFqn, singularizer, source); + return new SingularData(child, singularName, pluralName, typeArgs == null ? Collections.emptyList() : Arrays.asList(typeArgs), targetFqn, singularizer, source, setterPrefix.toCharArray()); } - + return null; } } diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java index 338f5eaba0..8f80d2289b 100755 --- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java +++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java @@ -172,7 +172,8 @@ void generateSingularMethod(CheckerFrameworkVersion cfv, boolean deprecate, Type md.arguments[i].annotations = typeUseAnns; } md.returnType = returnType; - md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName(getAddMethodName(), new String(data.getSingularName())).toCharArray(); + char[] prefixedSingularName = data.getSetterPrefix().length == 0 ? data.getSingularName() : HandlerUtil.buildAccessorName(new String(data.getSetterPrefix()), new String(data.getSingularName())).toCharArray(); + md.selector = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray(); md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource()); data.setGeneratedByRecursive(md); @@ -204,7 +205,8 @@ void generatePluralMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeRe Argument param = new Argument(data.getPluralName(), 0, paramType, ClassFileConstants.AccFinal); md.arguments = new Argument[] {param}; md.returnType = returnType; - md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName(getAddMethodName() + "All", new String(data.getPluralName())).toCharArray(); + char[] prefixedSelector = data.getSetterPrefix().length == 0 ? data.getPluralName() : HandlerUtil.buildAccessorName(new String(data.getSetterPrefix()), new String(data.getPluralName())).toCharArray(); + md.selector = fluent ? prefixedSelector : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray(); md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource()); data.setGeneratedByRecursive(md); diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java index 53ea15a68c..e3a990081b 100755 --- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java +++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java @@ -150,7 +150,8 @@ void generateSingularMethod(CheckerFrameworkVersion cfv, boolean deprecate, Type param.annotations = typeUseAnns; md.arguments = new Argument[] {param}; md.returnType = returnType; - md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray(); + char[] prefixedSingularName = data.getSetterPrefix().length == 0 ? data.getSingularName() : HandlerUtil.buildAccessorName(new String(data.getSetterPrefix()), new String(data.getSingularName())).toCharArray(); + md.selector = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray(); md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource()); data.setGeneratedByRecursive(md); @@ -181,7 +182,8 @@ void generatePluralMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeRe Argument param = new Argument(data.getPluralName(), 0, paramType, ClassFileConstants.AccFinal); md.arguments = new Argument[] {param}; md.returnType = returnType; - md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray(); + char[] prefixedSelector = data.getSetterPrefix().length == 0 ? data.getPluralName() : HandlerUtil.buildAccessorName(new String(data.getSetterPrefix()), new String(data.getPluralName())).toCharArray(); + md.selector = fluent ? prefixedSelector : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray(); md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource()); data.setGeneratedByRecursive(md); diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java index 8684987f02..4ceafd1ebb 100755 --- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java +++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.logging.Handler; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.compiler.ast.Argument; @@ -62,6 +63,7 @@ import lombok.eclipse.handlers.EclipseSingularsRecipes.StatementMaker; import lombok.eclipse.handlers.EclipseSingularsRecipes.TypeReferenceMaker; import lombok.eclipse.handlers.HandleNonNull; +import org.objectweb.asm.Handle; @ProviderFor(EclipseSingularizer.class) public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer { @@ -245,7 +247,13 @@ private void generateSingularMethod(CheckerFrameworkVersion cfv, boolean depreca valueParam.annotations = typeUseAnnsValue; md.arguments = new Argument[] {keyParam, valueParam}; md.returnType = returnType; - md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("put", new String(data.getSingularName())).toCharArray(); + + String name = new String(data.getSingularName()); + String setterPrefix = new String(data.getSetterPrefix()); + String prefixedSingularName = setterPrefix.isEmpty() ? name : HandlerUtil.buildAccessorName(setterPrefix, name); + String setterName = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName("put", name); + + md.selector = setterName.toCharArray(); md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource()); data.setGeneratedByRecursive(md); @@ -309,7 +317,13 @@ private void generatePluralMethod(CheckerFrameworkVersion cfv, boolean deprecate Argument param = new Argument(data.getPluralName(), 0, paramType, ClassFileConstants.AccFinal); md.arguments = new Argument[] {param}; md.returnType = returnType; - md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("putAll", new String(data.getPluralName())).toCharArray(); + + String name = new String(data.getPluralName()); + String setterPrefix = new String(data.getSetterPrefix()); + String prefixedSingularName = setterPrefix.isEmpty() ? name : HandlerUtil.buildAccessorName(setterPrefix, name); + String setterName = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName("put", name); + + md.selector = setterName.toCharArray(); md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource()); data.setGeneratedByRecursive(md); diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java index de2bdde1c5..46cb9b9a83 100644 --- a/src/core/lombok/javac/handlers/HandleBuilder.java +++ b/src/core/lombok/javac/handlers/HandleBuilder.java @@ -104,7 +104,7 @@ static class BuilderFieldData { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.BUILDER_FLAG_USAGE, "@Builder"); CheckerFrameworkVersion cfv = getCheckerFrameworkVersion(annotationNode); - + Builder builderInstance = annotation.getInstance(); AccessLevel accessForOuters = builderInstance.access(); if (accessForOuters == null) accessForOuters = AccessLevel.PUBLIC; @@ -180,7 +180,7 @@ static class BuilderFieldData { bfd.builderFieldName = bfd.name; bfd.annotations = findCopyableAnnotations(fieldNode); bfd.type = fd.vartype; - bfd.singularData = getSingularData(fieldNode); + bfd.singularData = getSingularData(fieldNode, builderInstance.setterPrefix()); bfd.originalFieldNode = fieldNode; if (bfd.singularData != null && isDefault != null) { @@ -369,7 +369,7 @@ static class BuilderFieldData { bfd.rawName = raw.name; bfd.annotations = findCopyableAnnotations(param); bfd.type = raw.vartype; - bfd.singularData = getSingularData(param); + bfd.singularData = getSingularData(param, builderInstance.setterPrefix()); bfd.originalFieldNode = param; addObtainVia(bfd, param); builderFields.add(bfd); @@ -436,7 +436,7 @@ static class BuilderFieldData { } for (BuilderFieldData bfd : builderFields) { - makeSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, fluent, chain, accessForInners); + makePrefixedSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, fluent, chain, accessForInners, builderInstance.setterPrefix()); } { @@ -487,7 +487,7 @@ static class BuilderFieldData { } tps = lb.toList(); } - JCMethodDecl md = generateToBuilderMethod(cfv, toBuilderMethodName, builderClassName, tdParent, tps, builderFields, fluent, ast, accessForOuters); + JCMethodDecl md = generateToBuilderMethod(cfv, toBuilderMethodName, builderClassName, tdParent, tps, builderFields, fluent, ast, accessForOuters, builderInstance.setterPrefix()); if (md != null) { recursiveSetGeneratedBy(md, ast, annotationNode.getContext()); injectMethod(tdParent, md); @@ -536,7 +536,7 @@ private static void unpack(StringBuilder sb, JCExpression expr) { } private static final String BUILDER_TEMP_VAR = "builder"; - private JCMethodDecl generateToBuilderMethod(CheckerFrameworkVersion cfv, String toBuilderMethodName, String builderClassName, JavacNode type, List typeParams, java.util.List builderFields, boolean fluent, JCAnnotation ast, AccessLevel access) { + private JCMethodDecl generateToBuilderMethod(CheckerFrameworkVersion cfv, String toBuilderMethodName, String builderClassName, JavacNode type, List typeParams, java.util.List builderFields, boolean fluent, JCAnnotation ast, AccessLevel access, String prefix) { // return new ThingieBuilder().setA(this.a).setB(this.b); JavacTreeMaker maker = type.getTreeMaker(); @@ -549,7 +549,13 @@ private JCMethodDecl generateToBuilderMethod(CheckerFrameworkVersion cfv, String JCExpression invoke = call; ListBuffer statements = new ListBuffer(); for (BuilderFieldData bfd : builderFields) { - Name setterName = fluent ? bfd.name : type.toName(HandlerUtil.buildAccessorName("set", bfd.name.toString())); + String prefixedSetterName; + if(fluent) { + prefixedSetterName = prefix.isEmpty() ? bfd.name.toString() : HandlerUtil.buildAccessorName(prefix, bfd.name.toString()); + } else { + prefixedSetterName = HandlerUtil.buildAccessorName(prefix, bfd.name.toString()); + } + Name setterName = type.toName(prefixedSetterName); JCExpression[] tgt = new JCExpression[bfd.singularData == null ? 1 : 2]; if (bfd.obtainVia == null || !bfd.obtainVia.field().isEmpty()) { for (int i = 0; i < tgt.length; i++) { @@ -622,12 +628,12 @@ private JCMethodDecl generateCleanMethod(java.util.List builde static List generateBuildArgs(CheckerFrameworkVersion cfv, JavacNode type, java.util.List builderFields) { if (!cfv.generateCalledMethods()) return List.nil(); - + ArrayList mandatories = new ArrayList(); for (BuilderFieldData bfd : builderFields) { if (bfd.singularData == null && bfd.nameOfSetFlag == null) mandatories.add(bfd.name.toString()); } - + JCExpression arg; JavacTreeMaker maker = type.getTreeMaker(); if (mandatories.size() == 0) return List.nil(); @@ -642,7 +648,7 @@ static List generateBuildArgs(CheckerFrameworkVersion cfv, Javac JCVariableDecl recv = maker.VarDef(maker.Modifiers(0L, List.of(recvAnno)), type.toName("this"), maker.Ident(builderTypeNode.name), null); return List.of(recv); } - + private JCMethodDecl generateBuildMethod(CheckerFrameworkVersion cfv, JavacNode tdParent, boolean isStatic, String buildName, Name builderName, JCExpression returnType, java.util.List builderFields, JavacNode type, List thrownExceptions, JCTree source, boolean addCleaning, AccessLevel access) { JavacTreeMaker maker = type.getTreeMaker(); @@ -787,18 +793,56 @@ public void makeSetterMethodsForBuilder(CheckerFrameworkVersion cfv, JavacNode b private void makeSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, boolean fluent, boolean chain, List annosOnParam, JavacNode originalFieldNode, AccessLevel access) { Name fieldName = ((JCVariableDecl) fieldNode.get()).name; - + for (JavacNode child : builderType.down()) { if (child.getKind() != Kind.METHOD) continue; JCMethodDecl methodDecl = (JCMethodDecl) child.get(); Name existingName = methodDecl.name; if (existingName.equals(fieldName) && !isTolerate(fieldNode, methodDecl)) return; } - + String setterName = fluent ? paramName.toString() : HandlerUtil.buildAccessorName("set", paramName.toString()); - + JavacTreeMaker maker = fieldNode.getTreeMaker(); - + + List methodAnns = JavacHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode); + JCMethodDecl newMethod = HandleSetter.createSetter(toJavacModifier(access), deprecate, fieldNode, maker, setterName, paramName, nameOfSetFlag, chain, source, methodAnns, annosOnParam); + recursiveSetGeneratedBy(newMethod, source.get(), builderType.getContext()); + copyJavadoc(originalFieldNode, newMethod, CopyJavadoc.SETTER); + + injectMethod(builderType, newMethod); + } + + public void makePrefixedSetterMethodsForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, BuilderFieldData fieldNode, JavacNode source, boolean fluent, boolean chain, AccessLevel access, String prefix) { + boolean deprecate = isFieldDeprecated(fieldNode.originalFieldNode); + if (fieldNode.singularData == null || fieldNode.singularData.getSingularizer() == null) { + makePrefixedSetterMethodForBuilder(cfv, builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, fluent, chain, fieldNode.annotations, fieldNode.originalFieldNode, access, prefix); + } else { + // TODO prefixed version + fieldNode.singularData.getSingularizer().generateMethods(cfv, fieldNode.singularData, deprecate, builderType, source.get(), fluent, chain, access); + } + } + + private void makePrefixedSetterMethodForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, boolean fluent, boolean chain, List annosOnParam, JavacNode originalFieldNode, AccessLevel access, String prefix) { + Name fieldName = ((JCVariableDecl) fieldNode.get()).name; + + String setterPrefix = prefix.isEmpty() ? "set" : prefix; + String setterName; + if(fluent) { + setterName = prefix.isEmpty() ? paramName.toString() : HandlerUtil.buildAccessorName(setterPrefix, paramName.toString()); + } else { + setterName = HandlerUtil.buildAccessorName(setterPrefix, paramName.toString()); + } + + for (JavacNode child : builderType.down()) { + if (child.getKind() != Kind.METHOD) continue; + JCMethodDecl methodDecl = (JCMethodDecl) child.get(); + Name existingName = methodDecl.name; + if (existingName.equals(builderType.toName(setterName)) && !isTolerate(fieldNode, methodDecl)) return; + } + + JavacTreeMaker maker = fieldNode.getTreeMaker(); + List methodAnns = JavacHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode); JCMethodDecl newMethod = HandleSetter.createSetter(toJavacModifier(access), deprecate, fieldNode, maker, setterName, paramName, nameOfSetFlag, chain, source, methodAnns, annosOnParam); if (cfv.generateCalledMethods()) { @@ -809,10 +853,10 @@ private void makeSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, Javac } recursiveSetGeneratedBy(newMethod, source.get(), builderType.getContext()); copyJavadoc(originalFieldNode, newMethod, CopyJavadoc.SETTER); - + injectMethod(builderType, newMethod); } - + public JavacNode makeBuilderClass(boolean isStatic, JavacNode source, JavacNode tdParent, String builderClassName, List typeParams, JCAnnotation ast, AccessLevel access) { JavacTreeMaker maker = tdParent.getTreeMaker(); int modifiers = toJavacModifier(access); @@ -838,8 +882,9 @@ private void addObtainVia(BuilderFieldData bfd, JavacNode node) { * or parameter), or null if there's no {@code @Singular} annotation on it. * * @param node The node (field or method param) to inspect for its name and potential {@code @Singular} annotation. + * @param setterPrefix */ - private SingularData getSingularData(JavacNode node) { + private SingularData getSingularData(JavacNode node, final String setterPrefix) { for (JavacNode child : node.down()) { if (!annotationTypeMatches(Singular.class, child)) continue; Name pluralName = node.getKind() == Kind.FIELD ? removePrefixFromField(node) : ((JCVariableDecl) node.get()).name; @@ -881,7 +926,7 @@ private SingularData getSingularData(JavacNode node) { return null; } - return new SingularData(child, singularName, pluralName, typeArgs, targetFqn, singularizer); + return new SingularData(child, singularName, pluralName, typeArgs, targetFqn, singularizer, setterPrefix); } return null; diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java index 341d44df77..10e6f9b4da 100644 --- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java +++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java @@ -117,6 +117,7 @@ public static final class SingularData { private final List typeArgs; private final String targetFqn; private final JavacSingularizer singularizer; + private final String setterPrefix; public SingularData(JavacNode annotation, Name singularName, Name pluralName, List typeArgs, String targetFqn, JavacSingularizer singularizer) { this.annotation = annotation; @@ -125,6 +126,17 @@ public SingularData(JavacNode annotation, Name singularName, Name pluralName, Li this.typeArgs = typeArgs; this.targetFqn = targetFqn; this.singularizer = singularizer; + this.setterPrefix = ""; + } + + public SingularData(JavacNode annotation, Name singularName, Name pluralName, List typeArgs, String targetFqn, JavacSingularizer singularizer, String setterPrefix) { + this.annotation = annotation; + this.singularName = singularName; + this.pluralName = pluralName; + this.typeArgs = typeArgs; + this.targetFqn = targetFqn; + this.singularizer = singularizer; + this.setterPrefix = setterPrefix; } public JavacNode getAnnotation() { @@ -138,6 +150,8 @@ public Name getSingularName() { public Name getPluralName() { return pluralName; } + + public String getSetterPrefix() { return setterPrefix; } public List getTypeArgs() { return typeArgs; @@ -279,8 +293,13 @@ private void generateSingularMethod(CheckerFrameworkVersion cfv, boolean depreca ListBuffer statements = generateSingularMethodStatements(maker, data, builderType, source); List params = generateSingularMethodParameters(maker, data, builderType, source); Name name = data.getSingularName(); - if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName(), name.toString())); - + String setterPrefix = data.getSetterPrefix(); + Name prefixedSingularName = setterPrefix.isEmpty() ? name : + builderType.toName(HandlerUtil.buildAccessorName(setterPrefix, name.toString())); + + name = fluent ? prefixedSingularName : builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName(), + name.toString())); + statements.prepend(createConstructBuilderVarIfNeeded(maker, data, builderType, source)); finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, params, access); } @@ -307,7 +326,10 @@ protected JCStatement generateSingularMethodAddStatement(JavacTreeMaker maker, J private void generatePluralMethod(CheckerFrameworkVersion cfv, boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent, AccessLevel access) { ListBuffer statements = generatePluralMethodStatements(maker, data, builderType, source); Name name = data.getPluralName(); - if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName() + "All", name.toString())); + + Name prefixedSingularName = data.getSetterPrefix().isEmpty() ? name : builderType.toName(HandlerUtil.buildAccessorName(data.getSetterPrefix(), data.getPluralName().toString())); + name = fluent ? prefixedSingularName + : builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName() + "All", name.toString())); JCExpression paramType = getPluralMethodParamType(builderType); paramType = addTypeArgs(getTypeArgumentsCount(), true, builderType, paramType, data.getTypeArgs(), source); long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext()); diff --git a/test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java new file mode 100644 index 0000000000..24ca09d6a5 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java @@ -0,0 +1,34 @@ +import java.util.List; +class BuilderSimpleWithSetterPrefix { + private int unprefixed; + @java.lang.SuppressWarnings("all") + BuilderSimpleWithSetterPrefix(final int unprefixed) { + this.unprefixed = unprefixed; + } + @java.lang.SuppressWarnings("all") + protected static class BuilderSimpleWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private int unprefixed; + @java.lang.SuppressWarnings("all") + BuilderSimpleWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSimpleWithSetterPrefixBuilder withUnprefixed(final int unprefixed) { + this.unprefixed = unprefixed; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSimpleWithSetterPrefix build() { + return new BuilderSimpleWithSetterPrefix(unprefixed); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSimpleWithSetterPrefix.BuilderSimpleWithSetterPrefixBuilder(unprefixed=" + this.unprefixed + ")"; + } + } + @java.lang.SuppressWarnings("all") + protected static BuilderSimpleWithSetterPrefixBuilder builder() { + return new BuilderSimpleWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java new file mode 100644 index 0000000000..6e9c2cee71 --- /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 BuilderSingularAnnotatedTypesWithSetterPrefix { + private Set<@MyAnnotation @NonNull String> foos; + private Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars; + @java.lang.SuppressWarnings("all") + BuilderSingularAnnotatedTypesWithSetterPrefix(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 BuilderSingularAnnotatedTypesWithSetterPrefixBuilder { + @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") + BuilderSingularAnnotatedTypesWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularAnnotatedTypesWithSetterPrefixBuilder 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 BuilderSingularAnnotatedTypesWithSetterPrefixBuilder 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 BuilderSingularAnnotatedTypesWithSetterPrefixBuilder clearFoos() { + if (this.foos != null) this.foos.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularAnnotatedTypesWithSetterPrefixBuilder 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 BuilderSingularAnnotatedTypesWithSetterPrefixBuilder 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 BuilderSingularAnnotatedTypesWithSetterPrefixBuilder clearBars() { + if (this.bars$key != null) { + this.bars$key.clear(); + this.bars$value.clear(); + } + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularAnnotatedTypesWithSetterPrefix 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 BuilderSingularAnnotatedTypesWithSetterPrefix(foos, bars); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularAnnotatedTypesWithSetterPrefix.BuilderSingularAnnotatedTypesWithSetterPrefixBuilder(foos=" + this.foos + ", bars$key=" + this.bars$key + ", bars$value=" + this.bars$value + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularAnnotatedTypesWithSetterPrefixBuilder builder() { + return new BuilderSingularAnnotatedTypesWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularGuavaListsSetsWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularGuavaListsSetsWithSetterPrefix.java new file mode 100644 index 0000000000..b349b16012 --- /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 BuilderSingularGuavaListsSetsWithSetterPrefix { + private ImmutableList cards; + private ImmutableCollection frogs; + @SuppressWarnings("all") + private ImmutableSet rawSet; + private ImmutableSortedSet passes; + private ImmutableTable users; + @java.lang.SuppressWarnings("all") + BuilderSingularGuavaListsSetsWithSetterPrefix(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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder { + @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") + BuilderSingularGuavaListsSetsWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder clearCards() { + this.cards = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder clearFrogs() { + this.frogs = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder clearRawSet() { + this.rawSet = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder clearPasses() { + this.passes = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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 BuilderSingularGuavaListsSetsWithSetterPrefixBuilder clearUsers() { + this.users = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaListsSetsWithSetterPrefix 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 BuilderSingularGuavaListsSetsWithSetterPrefix(cards, frogs, rawSet, passes, users); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularGuavaListsSetsWithSetterPrefix.BuilderSingularGuavaListsSetsWithSetterPrefixBuilder(cards=" + this.cards + ", frogs=" + this.frogs + ", rawSet=" + this.rawSet + ", passes=" + this.passes + ", users=" + this.users + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularGuavaListsSetsWithSetterPrefixBuilder builder() { + return new BuilderSingularGuavaListsSetsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularGuavaMapsWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularGuavaMapsWithSetterPrefix.java new file mode 100644 index 0000000000..b31628548f --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularGuavaMapsWithSetterPrefix.java @@ -0,0 +1,94 @@ +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableBiMap; +import com.google.common.collect.ImmutableSortedMap; +class BuilderSingularGuavaMapsWithSetterPrefix { + private ImmutableMap battleaxes; + private ImmutableSortedMap vertices; + @SuppressWarnings("all") + private ImmutableBiMap rawMap; + @java.lang.SuppressWarnings("all") + BuilderSingularGuavaMapsWithSetterPrefix(final ImmutableMap battleaxes, final ImmutableSortedMap vertices, final ImmutableBiMap rawMap) { + this.battleaxes = battleaxes; + this.vertices = vertices; + this.rawMap = rawMap; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingularGuavaMapsWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableMap.Builder battleaxes; + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableSortedMap.Builder vertices; + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableBiMap.Builder rawMap; + @java.lang.SuppressWarnings("all") + BuilderSingularGuavaMapsWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaMapsWithSetterPrefixBuilder withBattleaxe(final K key, final V value) { + if (this.battleaxes == null) this.battleaxes = com.google.common.collect.ImmutableMap.builder(); + this.battleaxes.put(key, value); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaMapsWithSetterPrefixBuilder withBattleaxes(final java.util.Map battleaxes) { + if (this.battleaxes == null) this.battleaxes = com.google.common.collect.ImmutableMap.builder(); + this.battleaxes.putAll(battleaxes); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaMapsWithSetterPrefixBuilder clearBattleaxes() { + this.battleaxes = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaMapsWithSetterPrefixBuilder withVertex(final Integer key, final V value) { + if (this.vertices == null) this.vertices = com.google.common.collect.ImmutableSortedMap.naturalOrder(); + this.vertices.put(key, value); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaMapsWithSetterPrefixBuilder withVertices(final java.util.Map vertices) { + if (this.vertices == null) this.vertices = com.google.common.collect.ImmutableSortedMap.naturalOrder(); + this.vertices.putAll(vertices); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaMapsWithSetterPrefixBuilder clearVertices() { + this.vertices = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaMapsWithSetterPrefixBuilder withRawMap(final java.lang.Object key, final java.lang.Object value) { + if (this.rawMap == null) this.rawMap = com.google.common.collect.ImmutableBiMap.builder(); + this.rawMap.put(key, value); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaMapsWithSetterPrefixBuilder withRawMap(final java.util.Map rawMap) { + if (this.rawMap == null) this.rawMap = com.google.common.collect.ImmutableBiMap.builder(); + this.rawMap.putAll(rawMap); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaMapsWithSetterPrefixBuilder clearRawMap() { + this.rawMap = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularGuavaMapsWithSetterPrefix build() { + com.google.common.collect.ImmutableMap battleaxes = this.battleaxes == null ? com.google.common.collect.ImmutableMap.of() : this.battleaxes.build(); + com.google.common.collect.ImmutableSortedMap vertices = this.vertices == null ? com.google.common.collect.ImmutableSortedMap.of() : this.vertices.build(); + com.google.common.collect.ImmutableBiMap rawMap = this.rawMap == null ? com.google.common.collect.ImmutableBiMap.of() : this.rawMap.build(); + return new BuilderSingularGuavaMapsWithSetterPrefix(battleaxes, vertices, rawMap); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularGuavaMapsWithSetterPrefix.BuilderSingularGuavaMapsWithSetterPrefixBuilder(battleaxes=" + this.battleaxes + ", vertices=" + this.vertices + ", rawMap=" + this.rawMap + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularGuavaMapsWithSetterPrefixBuilder builder() { + return new BuilderSingularGuavaMapsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularListsWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularListsWithSetterPrefix.java new file mode 100644 index 0000000000..c685a352f5 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularListsWithSetterPrefix.java @@ -0,0 +1,123 @@ +import java.util.List; +import java.util.Collection; +class BuilderSingularListsWithSetterPrefix { + private List children; + private Collection scarves; + @SuppressWarnings("all") + private List rawList; + @java.lang.SuppressWarnings("all") + BuilderSingularListsWithSetterPrefix(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 BuilderSingularListsWithSetterPrefixBuilder { + @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") + BuilderSingularListsWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsWithSetterPrefixBuilder 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 BuilderSingularListsWithSetterPrefixBuilder 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 BuilderSingularListsWithSetterPrefixBuilder clearChildren() { + if (this.children != null) this.children.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsWithSetterPrefixBuilder 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 BuilderSingularListsWithSetterPrefixBuilder 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 BuilderSingularListsWithSetterPrefixBuilder clearScarves() { + if (this.scarves != null) this.scarves.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsWithSetterPrefixBuilder 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 BuilderSingularListsWithSetterPrefixBuilder 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 BuilderSingularListsWithSetterPrefixBuilder clearRawList() { + if (this.rawList != null) this.rawList.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularListsWithSetterPrefix 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 BuilderSingularListsWithSetterPrefix(children, scarves, rawList); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularListsWithSetterPrefix.BuilderSingularListsWithSetterPrefixBuilder(children=" + this.children + ", scarves=" + this.scarves + ", rawList=" + this.rawList + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularListsWithSetterPrefixBuilder builder() { + return new BuilderSingularListsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularMapsWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularMapsWithSetterPrefix.java new file mode 100644 index 0000000000..a4afb8a8a4 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularMapsWithSetterPrefix.java @@ -0,0 +1,213 @@ +import java.util.Map; +import java.util.SortedMap; +class BuilderSingularMapsWithSetterPrefix { + private Map women; + private SortedMap men; + @SuppressWarnings("all") + private Map rawMap; + private Map stringMap; + @SuppressWarnings("all") + BuilderSingularMapsWithSetterPrefix(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 BuilderSingularMapsWithSetterPrefixBuilder { + @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") + BuilderSingularMapsWithSetterPrefixBuilder() { + } + @SuppressWarnings("all") + public BuilderSingularMapsWithSetterPrefixBuilder 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 BuilderSingularMapsWithSetterPrefixBuilder 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 BuilderSingularMapsWithSetterPrefixBuilder clearWomen() { + if (this.women$key != null) { + this.women$key.clear(); + this.women$value.clear(); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsWithSetterPrefixBuilder 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 BuilderSingularMapsWithSetterPrefixBuilder 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 BuilderSingularMapsWithSetterPrefixBuilder clearMen() { + if (this.men$key != null) { + this.men$key.clear(); + this.men$value.clear(); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsWithSetterPrefixBuilder withRawMap(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 BuilderSingularMapsWithSetterPrefixBuilder 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 BuilderSingularMapsWithSetterPrefixBuilder clearRawMap() { + if (this.rawMap$key != null) { + this.rawMap$key.clear(); + this.rawMap$value.clear(); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsWithSetterPrefixBuilder withStringMap(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 BuilderSingularMapsWithSetterPrefixBuilder withStringMap(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 BuilderSingularMapsWithSetterPrefixBuilder clearStringMap() { + if (this.stringMap$key != null) { + this.stringMap$key.clear(); + this.stringMap$value.clear(); + } + return this; + } + @SuppressWarnings("all") + public BuilderSingularMapsWithSetterPrefix 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 BuilderSingularMapsWithSetterPrefix(women, men, rawMap, stringMap); + } + @Override + @SuppressWarnings("all") + public String toString() { + return "BuilderSingularMapsWithSetterPrefix.BuilderSingularMapsWithSetterPrefixBuilder(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 BuilderSingularMapsWithSetterPrefixBuilder builder() { + return new BuilderSingularMapsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java new file mode 100644 index 0000000000..d2b5ff3788 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java @@ -0,0 +1,121 @@ +import java.util.List; +class BuilderSingularNoAutoWithSetterPrefix { + private List things; + private List widgets; + private List items; + @java.lang.SuppressWarnings("all") + BuilderSingularNoAutoWithSetterPrefix(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 BuilderSingularNoAutoWithSetterPrefixBuilder { + @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") + BuilderSingularNoAutoWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoWithSetterPrefixBuilder 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 BuilderSingularNoAutoWithSetterPrefixBuilder 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 BuilderSingularNoAutoWithSetterPrefixBuilder clearThings() { + if (this.things != null) this.things.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoWithSetterPrefixBuilder 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 BuilderSingularNoAutoWithSetterPrefixBuilder 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 BuilderSingularNoAutoWithSetterPrefixBuilder clearWidgets() { + if (this.widgets != null) this.widgets.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoWithSetterPrefixBuilder 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 BuilderSingularNoAutoWithSetterPrefixBuilder 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 BuilderSingularNoAutoWithSetterPrefixBuilder clearItems() { + if (this.items != null) this.items.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularNoAutoWithSetterPrefix 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 BuilderSingularNoAutoWithSetterPrefix(things, widgets, items); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularNoAutoWithSetterPrefix.BuilderSingularNoAutoWithSetterPrefixBuilder(things=" + this.things + ", widgets=" + this.widgets + ", items=" + this.items + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularNoAutoWithSetterPrefixBuilder builder() { + return new BuilderSingularNoAutoWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularRedirectToGuavaWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularRedirectToGuavaWithSetterPrefix.java new file mode 100644 index 0000000000..b0fe8135e9 --- /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 BuilderSingularRedirectToGuavaWithSetterPrefix { + private Set dangerMice; + private NavigableMap things; + private Collection> doohickeys; + @java.lang.SuppressWarnings("all") + BuilderSingularRedirectToGuavaWithSetterPrefix(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 BuilderSingularRedirectToGuavaWithSetterPrefixBuilder { + @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") + BuilderSingularRedirectToGuavaWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularRedirectToGuavaWithSetterPrefixBuilder 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 BuilderSingularRedirectToGuavaWithSetterPrefixBuilder 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 BuilderSingularRedirectToGuavaWithSetterPrefixBuilder clearDangerMice() { + this.dangerMice = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularRedirectToGuavaWithSetterPrefixBuilder 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 BuilderSingularRedirectToGuavaWithSetterPrefixBuilder 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 BuilderSingularRedirectToGuavaWithSetterPrefixBuilder clearThings() { + this.things = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularRedirectToGuavaWithSetterPrefixBuilder 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 BuilderSingularRedirectToGuavaWithSetterPrefixBuilder 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 BuilderSingularRedirectToGuavaWithSetterPrefixBuilder clearDoohickeys() { + this.doohickeys = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularRedirectToGuavaWithSetterPrefix 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 BuilderSingularRedirectToGuavaWithSetterPrefix(dangerMice, things, doohickeys); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularRedirectToGuavaWithSetterPrefix.BuilderSingularRedirectToGuavaWithSetterPrefixBuilder(dangerMice=" + this.dangerMice + ", things=" + this.things + ", doohickeys=" + this.doohickeys + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularRedirectToGuavaWithSetterPrefixBuilder builder() { + return new BuilderSingularRedirectToGuavaWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularSetsWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularSetsWithSetterPrefix.java new file mode 100644 index 0000000000..9702b8501a --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularSetsWithSetterPrefix.java @@ -0,0 +1,153 @@ +import java.util.Set; +import java.util.SortedSet; +class BuilderSingularSetsWithSetterPrefix { + private Set dangerMice; + private SortedSet octopodes; + @SuppressWarnings("all") + private Set rawSet; + private Set stringSet; + @java.lang.SuppressWarnings("all") + BuilderSingularSetsWithSetterPrefix(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 BuilderSingularSetsWithSetterPrefixBuilder { + @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") + BuilderSingularSetsWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsWithSetterPrefixBuilder 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 BuilderSingularSetsWithSetterPrefixBuilder 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 BuilderSingularSetsWithSetterPrefixBuilder clearDangerMice() { + if (this.dangerMice != null) this.dangerMice.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsWithSetterPrefixBuilder 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 BuilderSingularSetsWithSetterPrefixBuilder 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 BuilderSingularSetsWithSetterPrefixBuilder clearOctopodes() { + if (this.octopodes != null) this.octopodes.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsWithSetterPrefixBuilder 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 BuilderSingularSetsWithSetterPrefixBuilder 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 BuilderSingularSetsWithSetterPrefixBuilder clearRawSet() { + if (this.rawSet != null) this.rawSet.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsWithSetterPrefixBuilder 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 BuilderSingularSetsWithSetterPrefixBuilder 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 BuilderSingularSetsWithSetterPrefixBuilder clearStringSet() { + if (this.stringSet != null) this.stringSet.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularSetsWithSetterPrefix 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 BuilderSingularSetsWithSetterPrefix(dangerMice, octopodes, rawSet, stringSet); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularSetsWithSetterPrefix.BuilderSingularSetsWithSetterPrefixBuilder(dangerMice=" + this.dangerMice + ", octopodes=" + this.octopodes + ", rawSet=" + this.rawSet + ", stringSet=" + this.stringSet + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularSetsWithSetterPrefixBuilder builder() { + return new BuilderSingularSetsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularToBuilderWithNullWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularToBuilderWithNullWithSetterPrefix.java new file mode 100644 index 0000000000..5f42d87e00 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularToBuilderWithNullWithSetterPrefix.java @@ -0,0 +1,65 @@ +class BuilderSingularToBuilderWithNullWithSetterPrefix { + private java.util.List elems; + public static void test() { + new BuilderSingularToBuilderWithNullWithSetterPrefix(null).toBuilder(); + } + @java.lang.SuppressWarnings("all") + BuilderSingularToBuilderWithNullWithSetterPrefix(final java.util.List elems) { + this.elems = elems; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingularToBuilderWithNullWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private java.util.ArrayList elems; + @java.lang.SuppressWarnings("all") + BuilderSingularToBuilderWithNullWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularToBuilderWithNullWithSetterPrefixBuilder 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 BuilderSingularToBuilderWithNullWithSetterPrefixBuilder 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 BuilderSingularToBuilderWithNullWithSetterPrefixBuilder clearElems() { + if (this.elems != null) this.elems.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularToBuilderWithNullWithSetterPrefix 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 BuilderSingularToBuilderWithNullWithSetterPrefix(elems); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularToBuilderWithNullWithSetterPrefix.BuilderSingularToBuilderWithNullWithSetterPrefixBuilder(elems=" + this.elems + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularToBuilderWithNullWithSetterPrefixBuilder builder() { + return new BuilderSingularToBuilderWithNullWithSetterPrefixBuilder(); + } + @java.lang.SuppressWarnings("all") + public BuilderSingularToBuilderWithNullWithSetterPrefixBuilder toBuilder() { + final BuilderSingularToBuilderWithNullWithSetterPrefixBuilder builder = new BuilderSingularToBuilderWithNullWithSetterPrefixBuilder(); + if (this.elems != null) builder.withElems(this.elems); + return builder; + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java new file mode 100644 index 0000000000..367f0ac195 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java @@ -0,0 +1,97 @@ +import java.util.List; +import java.util.Collection; +class BuilderSingularWildcardListsWithToBuilderWithSetterPrefix { + private List objects; + private Collection numbers; + @java.lang.SuppressWarnings("all") + BuilderSingularWildcardListsWithToBuilderWithSetterPrefix(final List objects, final Collection numbers) { + this.objects = objects; + this.numbers = numbers; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private java.util.ArrayList objects; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList numbers; + @java.lang.SuppressWarnings("all") + BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder withObject(final java.lang.Object object) { + if (this.objects == null) this.objects = new java.util.ArrayList(); + this.objects.add(object); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder withObjects(final java.util.Collection objects) { + if (this.objects == null) this.objects = new java.util.ArrayList(); + this.objects.addAll(objects); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder clearObjects() { + if (this.objects != null) this.objects.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder withNumber(final Number number) { + if (this.numbers == null) this.numbers = new java.util.ArrayList(); + this.numbers.add(number); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder withNumbers(final java.util.Collection numbers) { + if (this.numbers == null) this.numbers = new java.util.ArrayList(); + this.numbers.addAll(numbers); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder clearNumbers() { + if (this.numbers != null) this.numbers.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularWildcardListsWithToBuilderWithSetterPrefix build() { + java.util.List objects; + switch (this.objects == null ? 0 : this.objects.size()) { + case 0: + objects = java.util.Collections.emptyList(); + break; + case 1: + objects = java.util.Collections.singletonList(this.objects.get(0)); + break; + default: + objects = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.objects)); + } + java.util.Collection numbers; + switch (this.numbers == null ? 0 : this.numbers.size()) { + case 0: + numbers = java.util.Collections.emptyList(); + break; + case 1: + numbers = java.util.Collections.singletonList(this.numbers.get(0)); + break; + default: + numbers = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.numbers)); + } + return new BuilderSingularWildcardListsWithToBuilderWithSetterPrefix(objects, numbers); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder(objects=" + this.objects + ", numbers=" + this.numbers + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder builder() { + return new BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder(); + } + @java.lang.SuppressWarnings("all") + public BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder toBuilder() { + final BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder builder = new BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder(); + if (this.objects != null) builder.withObjects(this.objects); + if (this.numbers != null) builder.withNumbers(this.numbers); + return builder; + } +} diff --git a/test/transform/resource/after-delombok/BuilderSingularWithPrefixesWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularWithPrefixesWithSetterPrefix.java new file mode 100644 index 0000000000..2f163caf35 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderSingularWithPrefixesWithSetterPrefix.java @@ -0,0 +1,56 @@ +class BuilderSingularWithPrefixesWithSetterPrefix { + private java.util.List _elems; + @java.lang.SuppressWarnings("all") + BuilderSingularWithPrefixesWithSetterPrefix(final java.util.List elems) { + this._elems = elems; + } + @java.lang.SuppressWarnings("all") + public static class BuilderSingularWithPrefixesWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private java.util.ArrayList elems; + @java.lang.SuppressWarnings("all") + BuilderSingularWithPrefixesWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderSingularWithPrefixesWithSetterPrefixBuilder 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 BuilderSingularWithPrefixesWithSetterPrefixBuilder 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 BuilderSingularWithPrefixesWithSetterPrefixBuilder clearElems() { + if (this.elems != null) this.elems.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderSingularWithPrefixesWithSetterPrefix 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 BuilderSingularWithPrefixesWithSetterPrefix(elems); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderSingularWithPrefixesWithSetterPrefix.BuilderSingularWithPrefixesWithSetterPrefixBuilder(elems=" + this.elems + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderSingularWithPrefixesWithSetterPrefixBuilder builder() { + return new BuilderSingularWithPrefixesWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderTypeAnnosWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderTypeAnnosWithSetterPrefix.java new file mode 100644 index 0000000000..0d4f805924 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderTypeAnnosWithSetterPrefix.java @@ -0,0 +1,45 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.util.List; +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +@interface TA { +} +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +@interface TB { +} +class BuilderTypeAnnosWithSetterPrefix { + @TA + @TB + private List foo; + @java.lang.SuppressWarnings("all") + BuilderTypeAnnosWithSetterPrefix(@TA final List foo) { + this.foo = foo; + } + @java.lang.SuppressWarnings("all") + public static class BuilderTypeAnnosWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private List foo; + @java.lang.SuppressWarnings("all") + BuilderTypeAnnosWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderTypeAnnosWithSetterPrefixBuilder withFoo(@TA final List foo) { + this.foo = foo; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderTypeAnnosWithSetterPrefix build() { + return new BuilderTypeAnnosWithSetterPrefix(foo); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderTypeAnnosWithSetterPrefix.BuilderTypeAnnosWithSetterPrefixBuilder(foo=" + this.foo + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderTypeAnnosWithSetterPrefixBuilder builder() { + return new BuilderTypeAnnosWithSetterPrefixBuilder(); + } +} + diff --git a/test/transform/resource/after-delombok/BuilderValueDataWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderValueDataWithSetterPrefix.java new file mode 100644 index 0000000000..879052080d --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderValueDataWithSetterPrefix.java @@ -0,0 +1,109 @@ +import java.util.List; +final class BuilderAndValueWithSetterPrefix { + private final int zero = 0; + @java.lang.SuppressWarnings("all") + BuilderAndValueWithSetterPrefix() { + } + @java.lang.SuppressWarnings("all") + public static class BuilderAndValueWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + BuilderAndValueWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderAndValueWithSetterPrefix build() { + return new BuilderAndValueWithSetterPrefix(); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderAndValueWithSetterPrefix.BuilderAndValueWithSetterPrefixBuilder()"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderAndValueWithSetterPrefixBuilder builder() { + return new BuilderAndValueWithSetterPrefixBuilder(); + } + @java.lang.SuppressWarnings("all") + public int getZero() { + return this.zero; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public boolean equals(final java.lang.Object o) { + if (o == this) return true; + if (!(o instanceof BuilderAndValueWithSetterPrefix)) return false; + final BuilderAndValueWithSetterPrefix other = (BuilderAndValueWithSetterPrefix) o; + if (this.getZero() != other.getZero()) return false; + return true; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public int hashCode() { + final int PRIME = 59; + int result = 1; + result = result * PRIME + this.getZero(); + return result; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderAndValueWithSetterPrefix(zero=" + this.getZero() + ")"; + } +} + +class BuilderAndDataWithSetterPrefix { + private final int zero = 0; + @java.lang.SuppressWarnings("all") + BuilderAndDataWithSetterPrefix() { + } + @java.lang.SuppressWarnings("all") + public static class BuilderAndDataWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + BuilderAndDataWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderAndDataWithSetterPrefix build() { + return new BuilderAndDataWithSetterPrefix(); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderAndDataWithSetterPrefix.BuilderAndDataWithSetterPrefixBuilder()"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderAndDataWithSetterPrefixBuilder builder() { + return new BuilderAndDataWithSetterPrefixBuilder(); + } + @java.lang.SuppressWarnings("all") + public int getZero() { + return this.zero; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public boolean equals(final java.lang.Object o) { + if (o == this) return true; + if (!(o instanceof BuilderAndDataWithSetterPrefix)) return false; + final BuilderAndDataWithSetterPrefix other = (BuilderAndDataWithSetterPrefix) o; + if (!other.canEqual((java.lang.Object) this)) return false; + if (this.getZero() != other.getZero()) return false; + return true; + } + @java.lang.SuppressWarnings("all") + protected boolean canEqual(final java.lang.Object other) { + return other instanceof BuilderAndDataWithSetterPrefix; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public int hashCode() { + final int PRIME = 59; + int result = 1; + result = result * PRIME + this.getZero(); + return result; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderAndDataWithSetterPrefix(zero=" + this.getZero() + ")"; + } +} diff --git a/test/transform/resource/after-delombok/BuilderWithAccessorsWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithAccessorsWithSetterPrefix.java new file mode 100644 index 0000000000..45a79fdcd2 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithAccessorsWithSetterPrefix.java @@ -0,0 +1,60 @@ +class BuilderWithAccessorsWithSetterPrefix { + private final int plower; + private final int pUpper; + private int _foo; + private int __bar; + @java.lang.SuppressWarnings("all") + BuilderWithAccessorsWithSetterPrefix(final int plower, final int upper, final int foo, final int _bar) { + this.plower = plower; + this.pUpper = upper; + this._foo = foo; + this.__bar = _bar; + } + @java.lang.SuppressWarnings("all") + public static class BuilderWithAccessorsWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private int plower; + @java.lang.SuppressWarnings("all") + private int upper; + @java.lang.SuppressWarnings("all") + private int foo; + @java.lang.SuppressWarnings("all") + private int _bar; + @java.lang.SuppressWarnings("all") + BuilderWithAccessorsWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderWithAccessorsWithSetterPrefixBuilder withPlower(final int plower) { + this.plower = plower; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithAccessorsWithSetterPrefixBuilder withUpper(final int upper) { + this.upper = upper; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithAccessorsWithSetterPrefixBuilder withFoo(final int foo) { + this.foo = foo; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithAccessorsWithSetterPrefixBuilder with_bar(final int _bar) { + this._bar = _bar; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithAccessorsWithSetterPrefix build() { + return new BuilderWithAccessorsWithSetterPrefix(plower, upper, foo, _bar); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithAccessorsWithSetterPrefix.BuilderWithAccessorsWithSetterPrefixBuilder(plower=" + this.plower + ", upper=" + this.upper + ", foo=" + this.foo + ", _bar=" + this._bar + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderWithAccessorsWithSetterPrefixBuilder builder() { + return new BuilderWithAccessorsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderWithBadNamesWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithBadNamesWithSetterPrefix.java new file mode 100644 index 0000000000..be7a78c72a --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithBadNamesWithSetterPrefix.java @@ -0,0 +1,42 @@ +public class BuilderWithBadNamesWithSetterPrefix { + String build; + String toString; + @java.lang.SuppressWarnings("all") + BuilderWithBadNamesWithSetterPrefix(final String build, final String toString) { + this.build = build; + this.toString = toString; + } + @java.lang.SuppressWarnings("all") + public static class BuilderWithBadNamesWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private String build; + @java.lang.SuppressWarnings("all") + private String toString; + @java.lang.SuppressWarnings("all") + BuilderWithBadNamesWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderWithBadNamesWithSetterPrefixBuilder withBuild(final String build) { + this.build = build; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithBadNamesWithSetterPrefixBuilder withToString(final String toString) { + this.toString = toString; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithBadNamesWithSetterPrefix build() { + return new BuilderWithBadNamesWithSetterPrefix(build, toString); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithBadNamesWithSetterPrefix.BuilderWithBadNamesWithSetterPrefixBuilder(build=" + this.build + ", toString=" + this.toString + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderWithBadNamesWithSetterPrefixBuilder builder() { + return new BuilderWithBadNamesWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderWithDeprecatedWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithDeprecatedWithSetterPrefix.java new file mode 100644 index 0000000000..5f6f2c3265 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithDeprecatedWithSetterPrefix.java @@ -0,0 +1,114 @@ +import com.google.common.collect.ImmutableList; +public class BuilderWithDeprecatedWithSetterPrefix { + /** + * @deprecated since always + */ + String dep1; + @Deprecated + int dep2; + @Deprecated + java.util.List strings; + @Deprecated + ImmutableList numbers; + @java.lang.SuppressWarnings("all") + BuilderWithDeprecatedWithSetterPrefix(final String dep1, final int dep2, final java.util.List strings, final ImmutableList numbers) { + this.dep1 = dep1; + this.dep2 = dep2; + this.strings = strings; + this.numbers = numbers; + } + @java.lang.SuppressWarnings("all") + public static class BuilderWithDeprecatedWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private String dep1; + @java.lang.SuppressWarnings("all") + private int dep2; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList strings; + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableList.Builder numbers; + @java.lang.SuppressWarnings("all") + BuilderWithDeprecatedWithSetterPrefixBuilder() { + } + /** + * @deprecated since always + */ + @java.lang.Deprecated + @java.lang.SuppressWarnings("all") + public BuilderWithDeprecatedWithSetterPrefixBuilder withDep1(final String dep1) { + this.dep1 = dep1; + return this; + } + @java.lang.Deprecated + @java.lang.SuppressWarnings("all") + public BuilderWithDeprecatedWithSetterPrefixBuilder withDep2(final int dep2) { + this.dep2 = dep2; + return this; + } + @java.lang.Deprecated + @java.lang.SuppressWarnings("all") + public BuilderWithDeprecatedWithSetterPrefixBuilder withString(final String string) { + if (this.strings == null) this.strings = new java.util.ArrayList(); + this.strings.add(string); + return this; + } + @java.lang.Deprecated + @java.lang.SuppressWarnings("all") + public BuilderWithDeprecatedWithSetterPrefixBuilder withStrings(final java.util.Collection strings) { + if (this.strings == null) this.strings = new java.util.ArrayList(); + this.strings.addAll(strings); + return this; + } + @java.lang.Deprecated + @java.lang.SuppressWarnings("all") + public BuilderWithDeprecatedWithSetterPrefixBuilder clearStrings() { + if (this.strings != null) this.strings.clear(); + return this; + } + @java.lang.Deprecated + @java.lang.SuppressWarnings("all") + public BuilderWithDeprecatedWithSetterPrefixBuilder withNumber(final Integer number) { + if (this.numbers == null) this.numbers = com.google.common.collect.ImmutableList.builder(); + this.numbers.add(number); + return this; + } + @java.lang.Deprecated + @java.lang.SuppressWarnings("all") + public BuilderWithDeprecatedWithSetterPrefixBuilder withNumbers(final java.lang.Iterable numbers) { + if (this.numbers == null) this.numbers = com.google.common.collect.ImmutableList.builder(); + this.numbers.addAll(numbers); + return this; + } + @java.lang.Deprecated + @java.lang.SuppressWarnings("all") + public BuilderWithDeprecatedWithSetterPrefixBuilder clearNumbers() { + this.numbers = null; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithDeprecatedWithSetterPrefix build() { + java.util.List strings; + switch (this.strings == null ? 0 : this.strings.size()) { + case 0: + strings = java.util.Collections.emptyList(); + break; + case 1: + strings = java.util.Collections.singletonList(this.strings.get(0)); + break; + default: + strings = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.strings)); + } + com.google.common.collect.ImmutableList numbers = this.numbers == null ? com.google.common.collect.ImmutableList.of() : this.numbers.build(); + return new BuilderWithDeprecatedWithSetterPrefix(dep1, dep2, strings, numbers); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithDeprecatedWithSetterPrefix.BuilderWithDeprecatedWithSetterPrefixBuilder(dep1=" + this.dep1 + ", dep2=" + this.dep2 + ", strings=" + this.strings + ", numbers=" + this.numbers + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderWithDeprecatedWithSetterPrefixBuilder builder() { + return new BuilderWithDeprecatedWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderWithExistingBuilderClassWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithExistingBuilderClassWithSetterPrefix.java new file mode 100644 index 0000000000..95f89c9d45 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithExistingBuilderClassWithSetterPrefix.java @@ -0,0 +1,40 @@ +class BuilderWithExistingBuilderClassWithSetterPrefix { + public static BuilderWithExistingBuilderClassWithSetterPrefix staticMethod(Z arg1, boolean arg2, String arg3) { + return null; + } + public static class BuilderWithExistingBuilderClassWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private boolean arg2; + @java.lang.SuppressWarnings("all") + private String arg3; + private Z arg1; + public void withArg2(boolean arg) { + } + @java.lang.SuppressWarnings("all") + BuilderWithExistingBuilderClassWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderWithExistingBuilderClassWithSetterPrefixBuilder withArg1(final Z arg1) { + this.arg1 = arg1; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithExistingBuilderClassWithSetterPrefixBuilder withArg3(final String arg3) { + this.arg3 = arg3; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithExistingBuilderClassWithSetterPrefix build() { + return BuilderWithExistingBuilderClassWithSetterPrefix.staticMethod(arg1, arg2, arg3); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithExistingBuilderClassWithSetterPrefix.BuilderWithExistingBuilderClassWithSetterPrefixBuilder(arg1=" + this.arg1 + ", arg2=" + this.arg2 + ", arg3=" + this.arg3 + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderWithExistingBuilderClassWithSetterPrefixBuilder builder() { + return new BuilderWithExistingBuilderClassWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderWithNoBuilderMethodWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithNoBuilderMethodWithSetterPrefix.java new file mode 100644 index 0000000000..0f478ed1a2 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithNoBuilderMethodWithSetterPrefix.java @@ -0,0 +1,33 @@ +class BuilderWithNoBuilderMethodWithSetterPrefix { + private String a = ""; + @java.lang.SuppressWarnings("all") + BuilderWithNoBuilderMethodWithSetterPrefix(final String a) { + this.a = a; + } + @java.lang.SuppressWarnings("all") + public static class BuilderWithNoBuilderMethodWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private String a; + @java.lang.SuppressWarnings("all") + BuilderWithNoBuilderMethodWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderWithNoBuilderMethodWithSetterPrefixBuilder withA(final String a) { + this.a = a; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithNoBuilderMethodWithSetterPrefix build() { + return new BuilderWithNoBuilderMethodWithSetterPrefix(a); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithNoBuilderMethodWithSetterPrefix.BuilderWithNoBuilderMethodWithSetterPrefixBuilder(a=" + this.a + ")"; + } + } + @java.lang.SuppressWarnings("all") + public BuilderWithNoBuilderMethodWithSetterPrefixBuilder toBuilder() { + return new BuilderWithNoBuilderMethodWithSetterPrefixBuilder().withA(this.a); + } +} diff --git a/test/transform/resource/after-delombok/BuilderWithNonNullWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithNonNullWithSetterPrefix.java new file mode 100644 index 0000000000..49be171750 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithNonNullWithSetterPrefix.java @@ -0,0 +1,40 @@ +class BuilderWithNonNullWithSetterPrefix { + @lombok.NonNull + private final String id; + @java.lang.SuppressWarnings("all") + BuilderWithNonNullWithSetterPrefix(@lombok.NonNull final String id) { + if (id == null) { + throw new java.lang.NullPointerException("id is marked non-null but is null"); + } + this.id = id; + } + @java.lang.SuppressWarnings("all") + public static class BuilderWithNonNullWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private String id; + @java.lang.SuppressWarnings("all") + BuilderWithNonNullWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderWithNonNullWithSetterPrefixBuilder withId(@lombok.NonNull final String id) { + if (id == null) { + throw new java.lang.NullPointerException("id is marked non-null but is null"); + } + this.id = id; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithNonNullWithSetterPrefix build() { + return new BuilderWithNonNullWithSetterPrefix(id); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithNonNullWithSetterPrefix.BuilderWithNonNullWithSetterPrefixBuilder(id=" + this.id + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderWithNonNullWithSetterPrefixBuilder builder() { + return new BuilderWithNonNullWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/BuilderWithRecursiveGenericsWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithRecursiveGenericsWithSetterPrefix.java new file mode 100644 index 0000000000..04494ff93c --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithRecursiveGenericsWithSetterPrefix.java @@ -0,0 +1,85 @@ +import java.util.Set; +public class BuilderWithRecursiveGenericsWithSetterPrefix { + interface Inter> { + } + public static final class Test, Quz extends Inter> { + private final Foo foo; + private final Bar bar; + @java.lang.SuppressWarnings("all") + Test(final Foo foo, final Bar bar) { + this.foo = foo; + this.bar = bar; + } + @java.lang.SuppressWarnings("all") + public static class TestBuilder, Quz extends Inter> { + @java.lang.SuppressWarnings("all") + private Foo foo; + @java.lang.SuppressWarnings("all") + private Bar bar; + @java.lang.SuppressWarnings("all") + TestBuilder() { + } + @java.lang.SuppressWarnings("all") + public TestBuilder withFoo(final Foo foo) { + this.foo = foo; + return this; + } + @java.lang.SuppressWarnings("all") + public TestBuilder withBar(final Bar bar) { + this.bar = bar; + return this; + } + @java.lang.SuppressWarnings("all") + public Test build() { + return new Test(foo, bar); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithRecursiveGenericsWithSetterPrefix.Test.TestBuilder(foo=" + this.foo + ", bar=" + this.bar + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static , Quz extends Inter> TestBuilder builder() { + return new TestBuilder(); + } + @java.lang.SuppressWarnings("all") + public Foo getFoo() { + return this.foo; + } + @java.lang.SuppressWarnings("all") + public Bar getBar() { + return this.bar; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public boolean equals(final java.lang.Object o) { + if (o == this) return true; + if (!(o instanceof BuilderWithRecursiveGenericsWithSetterPrefix.Test)) return false; + final BuilderWithRecursiveGenericsWithSetterPrefix.Test other = (BuilderWithRecursiveGenericsWithSetterPrefix.Test) o; + final java.lang.Object this$foo = this.getFoo(); + final java.lang.Object other$foo = other.getFoo(); + if (this$foo == null ? other$foo != null : !this$foo.equals(other$foo)) return false; + final java.lang.Object this$bar = this.getBar(); + final java.lang.Object other$bar = other.getBar(); + if (this$bar == null ? other$bar != null : !this$bar.equals(other$bar)) return false; + return true; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public int hashCode() { + final int PRIME = 59; + int result = 1; + final java.lang.Object $foo = this.getFoo(); + result = result * PRIME + ($foo == null ? 43 : $foo.hashCode()); + final java.lang.Object $bar = this.getBar(); + result = result * PRIME + ($bar == null ? 43 : $bar.hashCode()); + return result; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithRecursiveGenericsWithSetterPrefix.Test(foo=" + this.getFoo() + ", bar=" + this.getBar() + ")"; + } + } +} diff --git a/test/transform/resource/after-delombok/BuilderWithToBuilderWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithToBuilderWithSetterPrefix.java new file mode 100644 index 0000000000..322c667cc5 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithToBuilderWithSetterPrefix.java @@ -0,0 +1,146 @@ +import java.util.List; +class BuilderWithToBuilderWithSetterPrefix { + private String mOne; + private String mTwo; + private T foo; + private List bars; + public static K rrr(BuilderWithToBuilderWithSetterPrefix x) { + return x.foo; + } + @java.lang.SuppressWarnings("all") + BuilderWithToBuilderWithSetterPrefix(final String one, final String two, final T foo, final List bars) { + this.mOne = one; + this.mTwo = two; + this.foo = foo; + this.bars = bars; + } + @java.lang.SuppressWarnings("all") + public static class BuilderWithToBuilderWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private String one; + @java.lang.SuppressWarnings("all") + private String two; + @java.lang.SuppressWarnings("all") + private T foo; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList bars; + @java.lang.SuppressWarnings("all") + BuilderWithToBuilderWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderWithToBuilderWithSetterPrefixBuilder withOne(final String one) { + this.one = one; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithToBuilderWithSetterPrefixBuilder withTwo(final String two) { + this.two = two; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithToBuilderWithSetterPrefixBuilder withFoo(final T foo) { + this.foo = foo; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithToBuilderWithSetterPrefixBuilder withBar(final T bar) { + if (this.bars == null) this.bars = new java.util.ArrayList(); + this.bars.add(bar); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithToBuilderWithSetterPrefixBuilder withBars(final java.util.Collection bars) { + if (this.bars == null) this.bars = new java.util.ArrayList(); + this.bars.addAll(bars); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithToBuilderWithSetterPrefixBuilder clearBars() { + if (this.bars != null) this.bars.clear(); + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithToBuilderWithSetterPrefix build() { + java.util.List bars; + switch (this.bars == null ? 0 : this.bars.size()) { + case 0: + bars = java.util.Collections.emptyList(); + break; + case 1: + bars = java.util.Collections.singletonList(this.bars.get(0)); + break; + default: + bars = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.bars)); + } + return new BuilderWithToBuilderWithSetterPrefix(one, two, foo, bars); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithToBuilderWithSetterPrefix.BuilderWithToBuilderWithSetterPrefixBuilder(one=" + this.one + ", two=" + this.two + ", foo=" + this.foo + ", bars=" + this.bars + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static BuilderWithToBuilderWithSetterPrefixBuilder builder() { + return new BuilderWithToBuilderWithSetterPrefixBuilder(); + } + @java.lang.SuppressWarnings("all") + public BuilderWithToBuilderWithSetterPrefixBuilder toBuilder() { + final BuilderWithToBuilderWithSetterPrefixBuilder builder = new BuilderWithToBuilderWithSetterPrefixBuilder().withOne(this.mOne).withTwo(this.mTwo).withFoo(BuilderWithToBuilderWithSetterPrefix.rrr(this)); + if (this.bars != null) builder.withBars(this.bars); + return builder; + } +} +class ConstructorWithToBuilderWithSetterPrefix { + private String mOne; + private String mTwo; + private T foo; + @lombok.Singular + private com.google.common.collect.ImmutableList bars; + public ConstructorWithToBuilderWithSetterPrefix(String mOne, T baz, com.google.common.collect.ImmutableList bars) { + } + @java.lang.SuppressWarnings("all") + public static class ConstructorWithToBuilderWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private String mOne; + @java.lang.SuppressWarnings("all") + private T baz; + @java.lang.SuppressWarnings("all") + private com.google.common.collect.ImmutableList bars; + @java.lang.SuppressWarnings("all") + ConstructorWithToBuilderWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public ConstructorWithToBuilderWithSetterPrefixBuilder withMOne(final String mOne) { + this.mOne = mOne; + return this; + } + @java.lang.SuppressWarnings("all") + public ConstructorWithToBuilderWithSetterPrefixBuilder withBaz(final T baz) { + this.baz = baz; + return this; + } + @java.lang.SuppressWarnings("all") + public ConstructorWithToBuilderWithSetterPrefixBuilder withBars(final com.google.common.collect.ImmutableList bars) { + this.bars = bars; + return this; + } + @java.lang.SuppressWarnings("all") + public ConstructorWithToBuilderWithSetterPrefix build() { + return new ConstructorWithToBuilderWithSetterPrefix(mOne, baz, bars); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "ConstructorWithToBuilderWithSetterPrefix.ConstructorWithToBuilderWithSetterPrefixBuilder(mOne=" + this.mOne + ", baz=" + this.baz + ", bars=" + this.bars + ")"; + } + } + @java.lang.SuppressWarnings("all") + public static ConstructorWithToBuilderWithSetterPrefixBuilder builder() { + return new ConstructorWithToBuilderWithSetterPrefixBuilder(); + } + @java.lang.SuppressWarnings("all") + public ConstructorWithToBuilderWithSetterPrefixBuilder toBuilder() { + return new ConstructorWithToBuilderWithSetterPrefixBuilder().withMOne(this.mOne).withBaz(this.foo).withBars(this.bars); + } +} diff --git a/test/transform/resource/after-delombok/BuilderWithTolerateWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithTolerateWithSetterPrefix.java new file mode 100644 index 0000000000..70394d09c0 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithTolerateWithSetterPrefix.java @@ -0,0 +1,40 @@ +import lombok.experimental.Tolerate; +public class BuilderWithTolerateWithSetterPrefix { + private final int value; + public static void main(String[] args) { + BuilderWithTolerateWithSetterPrefix.builder().withValue("42").build(); + } + public static class BuilderWithTolerateWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") + private int value; + @Tolerate + public BuilderWithTolerateWithSetterPrefixBuilder withValue(String s) { + return this.withValue(Integer.parseInt(s)); + } + @java.lang.SuppressWarnings("all") + BuilderWithTolerateWithSetterPrefixBuilder() { + } + @java.lang.SuppressWarnings("all") + public BuilderWithTolerateWithSetterPrefixBuilder withValue(final int value) { + this.value = value; + return this; + } + @java.lang.SuppressWarnings("all") + public BuilderWithTolerateWithSetterPrefix build() { + return new BuilderWithTolerateWithSetterPrefix(value); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithTolerateWithSetterPrefix.BuilderWithTolerateWithSetterPrefixBuilder(value=" + this.value + ")"; + } + } + @java.lang.SuppressWarnings("all") + BuilderWithTolerateWithSetterPrefix(final int value) { + this.value = value; + } + @java.lang.SuppressWarnings("all") + public static BuilderWithTolerateWithSetterPrefixBuilder builder() { + return new BuilderWithTolerateWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderSimpleWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSimpleWithSetterPrefix.java new file mode 100644 index 0000000000..993c66daee --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSimpleWithSetterPrefix.java @@ -0,0 +1,27 @@ +import java.util.List; +@lombok.Builder(access = lombok.AccessLevel.PROTECTED,setterPrefix = "with") class BuilderSimpleWithSetterPrefix { + protected static @java.lang.SuppressWarnings("all") class BuilderSimpleWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") int unprefixed; + @java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefixBuilder withUnprefixed(final int unprefixed) { + this.unprefixed = unprefixed; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefix build() { + return new BuilderSimpleWithSetterPrefix(unprefixed); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("BuilderSimpleWithSetterPrefix.BuilderSimpleWithSetterPrefixBuilder(unprefixed=" + this.unprefixed) + ")"); + } + } + private int unprefixed; + @java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefix(final int unprefixed) { + super(); + this.unprefixed = unprefixed; + } + protected static @java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefixBuilder builder() { + return new BuilderSimpleWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularAnnotatedTypesWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularAnnotatedTypesWithSetterPrefix.java new file mode 100644 index 0000000000..c978ff403b --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularAnnotatedTypesWithSetterPrefix.java @@ -0,0 +1,121 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.util.Set; +import java.util.Map; +import lombok.NonNull; +import lombok.Singular; +@Target(ElementType.TYPE_USE) @interface MyAnnotation { +} +@lombok.Builder(setterPrefix = "with") class BuilderSingularAnnotatedTypesWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularAnnotatedTypesWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") java.util.ArrayList<@MyAnnotation @NonNull String> foos; + private @java.lang.SuppressWarnings("all") java.util.ArrayList<@MyAnnotation @NonNull String> bars$key; + private @java.lang.SuppressWarnings("all") java.util.ArrayList<@MyAnnotation @NonNull Integer> bars$value; + @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesWithSetterPrefixBuilder withFoo(final @MyAnnotation @NonNull 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesWithSetterPrefixBuilder 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesWithSetterPrefixBuilder clearFoos() { + if ((this.foos != null)) + this.foos.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesWithSetterPrefixBuilder withBar(final @MyAnnotation @NonNull String barKey, final @MyAnnotation @NonNull 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesWithSetterPrefixBuilder 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 (java.util.Map.Entry $lombokEntry : bars.entrySet()) + { + this.bars$key.add($lombokEntry.getKey()); + this.bars$value.add($lombokEntry.getValue()); + } + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesWithSetterPrefixBuilder clearBars() { + if ((this.bars$key != null)) + { + this.bars$key.clear(); + this.bars$value.clear(); + } + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesWithSetterPrefix 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() < 0x40000000) ? ((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() < 0x40000000) ? ((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), this.bars$value.get($i)); + bars = java.util.Collections.unmodifiableMap(bars); + } + return new BuilderSingularAnnotatedTypesWithSetterPrefix(foos, bars); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((("BuilderSingularAnnotatedTypesWithSetterPrefix.BuilderSingularAnnotatedTypesWithSetterPrefixBuilder(foos=" + this.foos) + ", bars$key=") + this.bars$key) + ", bars$value=") + this.bars$value) + ")"); + } + } + private @Singular Set<@MyAnnotation @NonNull String> foos; + private @Singular Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars; + @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesWithSetterPrefix(final Set<@MyAnnotation @NonNull String> foos, final Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars) { + super(); + this.foos = foos; + this.bars = bars; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesWithSetterPrefixBuilder builder() { + return new BuilderSingularAnnotatedTypesWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularGuavaListsSetsWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularGuavaListsSetsWithSetterPrefix.java new file mode 100644 index 0000000000..ec70087451 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularGuavaListsSetsWithSetterPrefix.java @@ -0,0 +1,125 @@ +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; +import lombok.Singular; +@lombok.Builder(setterPrefix = "with") class BuilderSingularGuavaListsSetsWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularGuavaListsSetsWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableList.Builder cards; + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableList.Builder frogs; + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableSet.Builder rawSet; + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableSortedSet.Builder passes; + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableTable.Builder users; + @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder withCard(final T card) { + if ((this.cards == null)) + this.cards = com.google.common.collect.ImmutableList.builder(); + this.cards.add(card); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder withCards(final java.lang.Iterable cards) { + if ((this.cards == null)) + this.cards = com.google.common.collect.ImmutableList.builder(); + this.cards.addAll(cards); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder clearCards() { + this.cards = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder withFrog(final Number frog) { + if ((this.frogs == null)) + this.frogs = com.google.common.collect.ImmutableList.builder(); + this.frogs.add(frog); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder withFrogs(final java.lang.Iterable frogs) { + if ((this.frogs == null)) + this.frogs = com.google.common.collect.ImmutableList.builder(); + this.frogs.addAll(frogs); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder clearFrogs() { + this.frogs = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder withRawSet(final java.lang.Object rawSet) { + if ((this.rawSet == null)) + this.rawSet = com.google.common.collect.ImmutableSet.builder(); + this.rawSet.add(rawSet); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder withRawSet(final java.lang.Iterable rawSet) { + if ((this.rawSet == null)) + this.rawSet = com.google.common.collect.ImmutableSet.builder(); + this.rawSet.addAll(rawSet); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder clearRawSet() { + this.rawSet = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder withPass(final String pass) { + if ((this.passes == null)) + this.passes = com.google.common.collect.ImmutableSortedSet.naturalOrder(); + this.passes.add(pass); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder withPasses(final java.lang.Iterable passes) { + if ((this.passes == null)) + this.passes = com.google.common.collect.ImmutableSortedSet.naturalOrder(); + this.passes.addAll(passes); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder clearPasses() { + this.passes = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder clearUsers() { + this.users = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefix 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 BuilderSingularGuavaListsSetsWithSetterPrefix(cards, frogs, rawSet, passes, users); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((((((("BuilderSingularGuavaListsSetsWithSetterPrefix.BuilderSingularGuavaListsSetsWithSetterPrefixBuilder(cards=" + this.cards) + ", frogs=") + this.frogs) + ", rawSet=") + this.rawSet) + ", passes=") + this.passes) + ", users=") + this.users) + ")"); + } + } + private @Singular ImmutableList cards; + private @Singular ImmutableCollection frogs; + private @SuppressWarnings("all") @Singular("rawSet") ImmutableSet rawSet; + private @Singular ImmutableSortedSet passes; + private @Singular ImmutableTable users; + @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefix(final ImmutableList cards, final ImmutableCollection frogs, final ImmutableSet rawSet, final ImmutableSortedSet passes, final ImmutableTable users) { + super(); + this.cards = cards; + this.frogs = frogs; + this.rawSet = rawSet; + this.passes = passes; + this.users = users; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularGuavaListsSetsWithSetterPrefixBuilder builder() { + return new BuilderSingularGuavaListsSetsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularGuavaMapsWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularGuavaMapsWithSetterPrefix.java new file mode 100644 index 0000000000..0f58f7a4ee --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularGuavaMapsWithSetterPrefix.java @@ -0,0 +1,83 @@ +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableBiMap; +import com.google.common.collect.ImmutableSortedMap; +import lombok.Singular; +@lombok.Builder(setterPrefix = "with") class BuilderSingularGuavaMapsWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularGuavaMapsWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableMap.Builder battleaxes; + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableSortedMap.Builder vertices; + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableBiMap.Builder rawMap; + @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder withBattleaxe(final K key, final V value) { + if ((this.battleaxes == null)) + this.battleaxes = com.google.common.collect.ImmutableMap.builder(); + this.battleaxes.put(key, value); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder withBattleaxes(final java.util.Map battleaxes) { + if ((this.battleaxes == null)) + this.battleaxes = com.google.common.collect.ImmutableMap.builder(); + this.battleaxes.putAll(battleaxes); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder clearBattleaxes() { + this.battleaxes = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder withVertex(final Integer key, final V value) { + if ((this.vertices == null)) + this.vertices = com.google.common.collect.ImmutableSortedMap.naturalOrder(); + this.vertices.put(key, value); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder withVertices(final java.util.Map vertices) { + if ((this.vertices == null)) + this.vertices = com.google.common.collect.ImmutableSortedMap.naturalOrder(); + this.vertices.putAll(vertices); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder clearVertices() { + this.vertices = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder withRawMap(final java.lang.Object key, final java.lang.Object value) { + if ((this.rawMap == null)) + this.rawMap = com.google.common.collect.ImmutableBiMap.builder(); + this.rawMap.put(key, value); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder withRawMap(final java.util.Map rawMap) { + if ((this.rawMap == null)) + this.rawMap = com.google.common.collect.ImmutableBiMap.builder(); + this.rawMap.putAll(rawMap); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder clearRawMap() { + this.rawMap = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefix build() { + com.google.common.collect.ImmutableMap battleaxes = ((this.battleaxes == null) ? com.google.common.collect.ImmutableMap.of() : this.battleaxes.build()); + com.google.common.collect.ImmutableSortedMap vertices = ((this.vertices == null) ? com.google.common.collect.ImmutableSortedMap.of() : this.vertices.build()); + com.google.common.collect.ImmutableBiMap rawMap = ((this.rawMap == null) ? com.google.common.collect.ImmutableBiMap.of() : this.rawMap.build()); + return new BuilderSingularGuavaMapsWithSetterPrefix(battleaxes, vertices, rawMap); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((("BuilderSingularGuavaMapsWithSetterPrefix.BuilderSingularGuavaMapsWithSetterPrefixBuilder(battleaxes=" + this.battleaxes) + ", vertices=") + this.vertices) + ", rawMap=") + this.rawMap) + ")"); + } + } + private @Singular ImmutableMap battleaxes; + private @Singular ImmutableSortedMap vertices; + private @SuppressWarnings("all") @Singular("rawMap") ImmutableBiMap rawMap; + @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefix(final ImmutableMap battleaxes, final ImmutableSortedMap vertices, final ImmutableBiMap rawMap) { + super(); + this.battleaxes = battleaxes; + this.vertices = vertices; + this.rawMap = rawMap; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularGuavaMapsWithSetterPrefixBuilder builder() { + return new BuilderSingularGuavaMapsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularListsWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularListsWithSetterPrefix.java new file mode 100644 index 0000000000..ab90cb481f --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularListsWithSetterPrefix.java @@ -0,0 +1,116 @@ +import java.util.List; +import java.util.Collection; + +import lombok.Singular; +@lombok.Builder(setterPrefix = "with") class BuilderSingularListsWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularListsWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") java.util.ArrayList children; + private @java.lang.SuppressWarnings("all") java.util.ArrayList scarves; + private @java.lang.SuppressWarnings("all") java.util.ArrayList rawList; + @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder withChild(final T child) { + if ((this.children == null)) + this.children = new java.util.ArrayList(); + this.children.add(child); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder withChildren(final java.util.Collection children) { + if ((this.children == null)) + this.children = new java.util.ArrayList(); + this.children.addAll(children); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder clearChildren() { + if ((this.children != null)) + this.children.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder withScarf(final Number scarf) { + if ((this.scarves == null)) + this.scarves = new java.util.ArrayList(); + this.scarves.add(scarf); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder withScarves(final java.util.Collection scarves) { + if ((this.scarves == null)) + this.scarves = new java.util.ArrayList(); + this.scarves.addAll(scarves); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder clearScarves() { + if ((this.scarves != null)) + this.scarves.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder withRawList(final java.lang.Object rawList) { + if ((this.rawList == null)) + this.rawList = new java.util.ArrayList(); + this.rawList.add(rawList); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder withRawList(final java.util.Collection rawList) { + if ((this.rawList == null)) + this.rawList = new java.util.ArrayList(); + this.rawList.addAll(rawList); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder clearRawList() { + if ((this.rawList != null)) + this.rawList.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefix 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 BuilderSingularListsWithSetterPrefix(children, scarves, rawList); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((("BuilderSingularListsWithSetterPrefix.BuilderSingularListsWithSetterPrefixBuilder(children=" + this.children) + ", scarves=") + this.scarves) + ", rawList=") + this.rawList) + ")"); + } + } + private @Singular List children; + private @Singular Collection scarves; + private @SuppressWarnings("all") @Singular("rawList") List rawList; + @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefix(final List children, final Collection scarves, final List rawList) { + super(); + this.children = children; + this.scarves = scarves; + this.rawList = rawList; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularListsWithSetterPrefixBuilder builder() { + return new BuilderSingularListsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularMapsWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularMapsWithSetterPrefix.java new file mode 100644 index 0000000000..7848b154f8 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularMapsWithSetterPrefix.java @@ -0,0 +1,209 @@ +import java.util.Map; +import java.util.SortedMap; +import lombok.Singular; +@lombok.Builder(setterPrefix = "with") class BuilderSingularMapsWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularMapsWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") java.util.ArrayList women$key; + private @java.lang.SuppressWarnings("all") java.util.ArrayList women$value; + private @java.lang.SuppressWarnings("all") java.util.ArrayList men$key; + private @java.lang.SuppressWarnings("all") java.util.ArrayList men$value; + private @java.lang.SuppressWarnings("all") java.util.ArrayList rawMap$key; + private @java.lang.SuppressWarnings("all") java.util.ArrayList rawMap$value; + private @java.lang.SuppressWarnings("all") java.util.ArrayList stringMap$key; + private @java.lang.SuppressWarnings("all") java.util.ArrayList stringMap$value; + @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder withWoman(final K womanKey, final 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder withWomen(final 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder clearWomen() { + if ((this.women$key != null)) + { + this.women$key.clear(); + this.women$value.clear(); + } + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder withMan(final K manKey, final 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder withMen(final 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder clearMen() { + if ((this.men$key != null)) + { + this.men$key.clear(); + this.men$value.clear(); + } + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder withRawMap(final java.lang.Object rawMapKey, final java.lang.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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder withRawMap(final 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder clearRawMap() { + if ((this.rawMap$key != null)) + { + this.rawMap$key.clear(); + this.rawMap$value.clear(); + } + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder withStringMap(final String stringMapKey, final 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder withStringMap(final 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder clearStringMap() { + if ((this.stringMap$key != null)) + { + this.stringMap$key.clear(); + this.stringMap$value.clear(); + } + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefix 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() < 0x40000000) ? ((1 + this.women$key.size()) + ((this.women$key.size() - 3) / 3)) : java.lang.Integer.MAX_VALUE)); + for (int $i = 0;; ($i < this.women$key.size()); $i ++) + women.put(this.women$key.get($i), 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), 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() < 0x40000000) ? ((1 + this.rawMap$key.size()) + ((this.rawMap$key.size() - 3) / 3)) : java.lang.Integer.MAX_VALUE)); + for (int $i = 0;; ($i < this.rawMap$key.size()); $i ++) + rawMap.put(this.rawMap$key.get($i), 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() < 0x40000000) ? ((1 + this.stringMap$key.size()) + ((this.stringMap$key.size() - 3) / 3)) : java.lang.Integer.MAX_VALUE)); + for (int $i = 0;; ($i < this.stringMap$key.size()); $i ++) + stringMap.put(this.stringMap$key.get($i), this.stringMap$value.get($i)); + stringMap = java.util.Collections.unmodifiableMap(stringMap); + } + return new BuilderSingularMapsWithSetterPrefix(women, men, rawMap, stringMap); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((((((((((((("BuilderSingularMapsWithSetterPrefix.BuilderSingularMapsWithSetterPrefixBuilder(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) + ")"); + } + } + private @Singular Map women; + private @Singular SortedMap men; + private @SuppressWarnings("all") @Singular("rawMap") Map rawMap; + private @Singular("stringMap") Map stringMap; + @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefix(final Map women, final SortedMap men, final Map rawMap, final Map stringMap) { + super(); + this.women = women; + this.men = men; + this.rawMap = rawMap; + this.stringMap = stringMap; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularMapsWithSetterPrefixBuilder builder() { + return new BuilderSingularMapsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularNoAutoWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularNoAutoWithSetterPrefix.java new file mode 100644 index 0000000000..f24b1640ba --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularNoAutoWithSetterPrefix.java @@ -0,0 +1,114 @@ +import java.util.List; +import lombok.Singular; +@lombok.Builder(setterPrefix = "with") class BuilderSingularNoAutoWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularNoAutoWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") java.util.ArrayList things; + private @java.lang.SuppressWarnings("all") java.util.ArrayList widgets; + private @java.lang.SuppressWarnings("all") java.util.ArrayList items; + @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder withThings(final String things) { + if ((this.things == null)) + this.things = new java.util.ArrayList(); + this.things.add(things); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder withThings(final java.util.Collection things) { + if ((this.things == null)) + this.things = new java.util.ArrayList(); + this.things.addAll(things); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder clearThings() { + if ((this.things != null)) + this.things.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder withWidget(final String widget) { + if ((this.widgets == null)) + this.widgets = new java.util.ArrayList(); + this.widgets.add(widget); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder withWidgets(final java.util.Collection widgets) { + if ((this.widgets == null)) + this.widgets = new java.util.ArrayList(); + this.widgets.addAll(widgets); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder clearWidgets() { + if ((this.widgets != null)) + this.widgets.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder withItems(final String items) { + if ((this.items == null)) + this.items = new java.util.ArrayList(); + this.items.add(items); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder withItems(final java.util.Collection items) { + if ((this.items == null)) + this.items = new java.util.ArrayList(); + this.items.addAll(items); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder clearItems() { + if ((this.items != null)) + this.items.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefix 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 BuilderSingularNoAutoWithSetterPrefix(things, widgets, items); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((("BuilderSingularNoAutoWithSetterPrefix.BuilderSingularNoAutoWithSetterPrefixBuilder(things=" + this.things) + ", widgets=") + this.widgets) + ", items=") + this.items) + ")"); + } + } + private @Singular List things; + private @Singular("widget") List widgets; + private @Singular List items; + @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefix(final List things, final List widgets, final List items) { + super(); + this.things = things; + this.widgets = widgets; + this.items = items; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularNoAutoWithSetterPrefixBuilder builder() { + return new BuilderSingularNoAutoWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularRedirectToGuavaWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularRedirectToGuavaWithSetterPrefix.java new file mode 100644 index 0000000000..c6e163cb53 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularRedirectToGuavaWithSetterPrefix.java @@ -0,0 +1,83 @@ +import java.util.Set; +import java.util.NavigableMap; +import java.util.Collection; +import lombok.Singular; +@lombok.Builder(setterPrefix = "with") class BuilderSingularRedirectToGuavaWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularRedirectToGuavaWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableSet.Builder dangerMice; + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableSortedMap.Builder things; + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableList.Builder> doohickeys; + @java.lang.SuppressWarnings("all") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder withDangerMouse(final 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") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder withDangerMice(final 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") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder clearDangerMice() { + this.dangerMice = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder 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; + } + public @java.lang.SuppressWarnings("all") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder withThings(final 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") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder clearThings() { + this.things = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder withDoohickey(final 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") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder withDoohickeys(final 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") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder clearDoohickeys() { + this.doohickeys = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularRedirectToGuavaWithSetterPrefix 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 BuilderSingularRedirectToGuavaWithSetterPrefix(dangerMice, things, doohickeys); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((("BuilderSingularRedirectToGuavaWithSetterPrefix.BuilderSingularRedirectToGuavaWithSetterPrefixBuilder(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") BuilderSingularRedirectToGuavaWithSetterPrefix(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") BuilderSingularRedirectToGuavaWithSetterPrefixBuilder builder() { + return new BuilderSingularRedirectToGuavaWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularSetsWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularSetsWithSetterPrefix.java new file mode 100644 index 0000000000..905e919047 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularSetsWithSetterPrefix.java @@ -0,0 +1,145 @@ +import java.util.Set; +import java.util.SortedSet; +import lombok.Singular; +@lombok.Builder(setterPrefix = "with") class BuilderSingularSetsWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularSetsWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") java.util.ArrayList dangerMice; + private @java.lang.SuppressWarnings("all") java.util.ArrayList octopodes; + private @java.lang.SuppressWarnings("all") java.util.ArrayList rawSet; + private @java.lang.SuppressWarnings("all") java.util.ArrayList stringSet; + @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder withDangerMouse(final T dangerMouse) { + if ((this.dangerMice == null)) + this.dangerMice = new java.util.ArrayList(); + this.dangerMice.add(dangerMouse); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder withDangerMice(final java.util.Collection dangerMice) { + if ((this.dangerMice == null)) + this.dangerMice = new java.util.ArrayList(); + this.dangerMice.addAll(dangerMice); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder clearDangerMice() { + if ((this.dangerMice != null)) + this.dangerMice.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder withOctopus(final Number octopus) { + if ((this.octopodes == null)) + this.octopodes = new java.util.ArrayList(); + this.octopodes.add(octopus); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder withOctopodes(final java.util.Collection octopodes) { + if ((this.octopodes == null)) + this.octopodes = new java.util.ArrayList(); + this.octopodes.addAll(octopodes); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder clearOctopodes() { + if ((this.octopodes != null)) + this.octopodes.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder withRawSet(final java.lang.Object rawSet) { + if ((this.rawSet == null)) + this.rawSet = new java.util.ArrayList(); + this.rawSet.add(rawSet); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder withRawSet(final java.util.Collection rawSet) { + if ((this.rawSet == null)) + this.rawSet = new java.util.ArrayList(); + this.rawSet.addAll(rawSet); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder clearRawSet() { + if ((this.rawSet != null)) + this.rawSet.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder withStringSet(final String stringSet) { + if ((this.stringSet == null)) + this.stringSet = new java.util.ArrayList(); + this.stringSet.add(stringSet); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder withStringSet(final java.util.Collection stringSet) { + if ((this.stringSet == null)) + this.stringSet = new java.util.ArrayList(); + this.stringSet.addAll(stringSet); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder clearStringSet() { + if ((this.stringSet != null)) + this.stringSet.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefix 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() < 0x40000000) ? ((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() < 0x40000000) ? ((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() < 0x40000000) ? ((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 BuilderSingularSetsWithSetterPrefix(dangerMice, octopodes, rawSet, stringSet); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((((("BuilderSingularSetsWithSetterPrefix.BuilderSingularSetsWithSetterPrefixBuilder(dangerMice=" + this.dangerMice) + ", octopodes=") + this.octopodes) + ", rawSet=") + this.rawSet) + ", stringSet=") + this.stringSet) + ")"); + } + } + private @Singular Set dangerMice; + private @Singular SortedSet octopodes; + private @SuppressWarnings("all") @Singular("rawSet") Set rawSet; + private @Singular("stringSet") Set stringSet; + @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefix(final Set dangerMice, final SortedSet octopodes, final Set rawSet, final Set stringSet) { + super(); + this.dangerMice = dangerMice; + this.octopodes = octopodes; + this.rawSet = rawSet; + this.stringSet = stringSet; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularSetsWithSetterPrefixBuilder builder() { + return new BuilderSingularSetsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularToBuilderWithNullWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularToBuilderWithNullWithSetterPrefix.java new file mode 100644 index 0000000000..ef2d02a1f9 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularToBuilderWithNullWithSetterPrefix.java @@ -0,0 +1,60 @@ +import lombok.Singular; +@lombok.Builder(toBuilder = true,setterPrefix = "with") class BuilderSingularToBuilderWithNullWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularToBuilderWithNullWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") java.util.ArrayList elems; + @java.lang.SuppressWarnings("all") BuilderSingularToBuilderWithNullWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularToBuilderWithNullWithSetterPrefixBuilder withElem(final String elem) { + if ((this.elems == null)) + this.elems = new java.util.ArrayList(); + this.elems.add(elem); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularToBuilderWithNullWithSetterPrefixBuilder withElems(final java.util.Collection elems) { + if ((this.elems == null)) + this.elems = new java.util.ArrayList(); + this.elems.addAll(elems); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularToBuilderWithNullWithSetterPrefixBuilder clearElems() { + if ((this.elems != null)) + this.elems.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularToBuilderWithNullWithSetterPrefix 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 BuilderSingularToBuilderWithNullWithSetterPrefix(elems); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("BuilderSingularToBuilderWithNullWithSetterPrefix.BuilderSingularToBuilderWithNullWithSetterPrefixBuilder(elems=" + this.elems) + ")"); + } + } + private @Singular java.util.List elems; + public static void test() { + new BuilderSingularToBuilderWithNullWithSetterPrefix(null).toBuilder(); + } + @java.lang.SuppressWarnings("all") BuilderSingularToBuilderWithNullWithSetterPrefix(final java.util.List elems) { + super(); + this.elems = elems; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularToBuilderWithNullWithSetterPrefixBuilder builder() { + return new BuilderSingularToBuilderWithNullWithSetterPrefixBuilder(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularToBuilderWithNullWithSetterPrefixBuilder toBuilder() { + final BuilderSingularToBuilderWithNullWithSetterPrefixBuilder builder = new BuilderSingularToBuilderWithNullWithSetterPrefixBuilder(); + if ((this.elems != null)) + builder.withElems(this.elems); + return builder; + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java new file mode 100644 index 0000000000..bbb1008749 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java @@ -0,0 +1,92 @@ +import java.util.List; +import java.util.Collection; +import lombok.Singular; +@lombok.Builder(toBuilder = true,setterPrefix = "with") class BuilderSingularWildcardListsWithToBuilderWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") java.util.ArrayList objects; + private @java.lang.SuppressWarnings("all") java.util.ArrayList numbers; + @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder withObject(final java.lang.Object object) { + if ((this.objects == null)) + this.objects = new java.util.ArrayList(); + this.objects.add(object); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder withObjects(final java.util.Collection objects) { + if ((this.objects == null)) + this.objects = new java.util.ArrayList(); + this.objects.addAll(objects); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder clearObjects() { + if ((this.objects != null)) + this.objects.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder withNumber(final Number number) { + if ((this.numbers == null)) + this.numbers = new java.util.ArrayList(); + this.numbers.add(number); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder withNumbers(final java.util.Collection numbers) { + if ((this.numbers == null)) + this.numbers = new java.util.ArrayList(); + this.numbers.addAll(numbers); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder clearNumbers() { + if ((this.numbers != null)) + this.numbers.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefix build() { + java.util.List objects; + switch (((this.objects == null) ? 0 : this.objects.size())) { + case 0 : + objects = java.util.Collections.emptyList(); + break; + case 1 : + objects = java.util.Collections.singletonList(this.objects.get(0)); + break; + default : + objects = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.objects)); + } + java.util.Collection numbers; + switch (((this.numbers == null) ? 0 : this.numbers.size())) { + case 0 : + numbers = java.util.Collections.emptyList(); + break; + case 1 : + numbers = java.util.Collections.singletonList(this.numbers.get(0)); + break; + default : + numbers = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.numbers)); + } + return new BuilderSingularWildcardListsWithToBuilderWithSetterPrefix(objects, numbers); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((("BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder(objects=" + this.objects) + ", numbers=") + this.numbers) + ")"); + } + } + private @Singular List objects; + private @Singular Collection numbers; + @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefix(final List objects, final Collection numbers) { + super(); + this.objects = objects; + this.numbers = numbers; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder builder() { + return new BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder toBuilder() { + final BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder builder = new BuilderSingularWildcardListsWithToBuilderWithSetterPrefixBuilder(); + if ((this.objects != null)) + builder.withObjects(this.objects); + if ((this.numbers != null)) + builder.withNumbers(this.numbers); + return builder; + } +} diff --git a/test/transform/resource/after-ecj/BuilderSingularWithPrefixesWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSingularWithPrefixesWithSetterPrefix.java new file mode 100644 index 0000000000..f3218f27c9 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderSingularWithPrefixesWithSetterPrefix.java @@ -0,0 +1,51 @@ +import lombok.Singular; +@lombok.Builder(setterPrefix = "with") @lombok.experimental.Accessors(prefix = "_") class BuilderSingularWithPrefixesWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderSingularWithPrefixesWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") java.util.ArrayList elems; + @java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefixBuilder withElem(final String elem) { + if ((this.elems == null)) + this.elems = new java.util.ArrayList(); + this.elems.add(elem); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefixBuilder withElems(final java.util.Collection elems) { + if ((this.elems == null)) + this.elems = new java.util.ArrayList(); + this.elems.addAll(elems); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefixBuilder clearElems() { + if ((this.elems != null)) + this.elems.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefix 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 BuilderSingularWithPrefixesWithSetterPrefix(elems); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("BuilderSingularWithPrefixesWithSetterPrefix.BuilderSingularWithPrefixesWithSetterPrefixBuilder(elems=" + this.elems) + ")"); + } + } + private @Singular java.util.List _elems; + @java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefix(final java.util.List elems) { + super(); + this._elems = elems; + } + public static @java.lang.SuppressWarnings("all") BuilderSingularWithPrefixesWithSetterPrefixBuilder builder() { + return new BuilderSingularWithPrefixesWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderTypeAnnosWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderTypeAnnosWithSetterPrefix.java new file mode 100644 index 0000000000..db44aa12f5 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderTypeAnnosWithSetterPrefix.java @@ -0,0 +1,33 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.util.List; +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @interface TA { +} +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @interface TB { +} +@lombok.Builder(setterPrefix = "with") class BuilderTypeAnnosWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderTypeAnnosWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") List foo; + @java.lang.SuppressWarnings("all") BuilderTypeAnnosWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderTypeAnnosWithSetterPrefixBuilder withFoo(final @TA List foo) { + this.foo = foo; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderTypeAnnosWithSetterPrefix build() { + return new BuilderTypeAnnosWithSetterPrefix(foo); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("BuilderTypeAnnosWithSetterPrefix.BuilderTypeAnnosWithSetterPrefixBuilder(foo=" + this.foo) + ")"); + } + } + private @TA @TB List foo; + @java.lang.SuppressWarnings("all") BuilderTypeAnnosWithSetterPrefix(final @TA List foo) { + super(); + this.foo = foo; + } + public static @java.lang.SuppressWarnings("all") BuilderTypeAnnosWithSetterPrefixBuilder builder() { + return new BuilderTypeAnnosWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderValueDataWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderValueDataWithSetterPrefix.java new file mode 100644 index 0000000000..065c93fe82 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderValueDataWithSetterPrefix.java @@ -0,0 +1,90 @@ +import java.util.List; +final @lombok.Builder(setterPrefix = "with") @lombok.Value class BuilderAndValueWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderAndValueWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") BuilderAndValueWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderAndValueWithSetterPrefix build() { + return new BuilderAndValueWithSetterPrefix(); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return "BuilderAndValueWithSetterPrefix.BuilderAndValueWithSetterPrefixBuilder()"; + } + } + private final int zero = 0; + @java.lang.SuppressWarnings("all") BuilderAndValueWithSetterPrefix() { + super(); + } + public static @java.lang.SuppressWarnings("all") BuilderAndValueWithSetterPrefixBuilder builder() { + return new BuilderAndValueWithSetterPrefixBuilder(); + } + public @java.lang.SuppressWarnings("all") int getZero() { + return this.zero; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { + if ((o == this)) + return true; + if ((! (o instanceof BuilderAndValueWithSetterPrefix))) + return false; + final BuilderAndValueWithSetterPrefix other = (BuilderAndValueWithSetterPrefix) o; + if ((this.getZero() != other.getZero())) + return false; + return true; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 59; + int result = 1; + result = ((result * PRIME) + this.getZero()); + return result; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("BuilderAndValueWithSetterPrefix(zero=" + this.getZero()) + ")"); + } +} +@lombok.Builder(setterPrefix = "with") @lombok.Data class BuilderAndDataWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderAndDataWithSetterPrefixBuilder { + @java.lang.SuppressWarnings("all") BuilderAndDataWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderAndDataWithSetterPrefix build() { + return new BuilderAndDataWithSetterPrefix(); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return "BuilderAndDataWithSetterPrefix.BuilderAndDataWithSetterPrefixBuilder()"; + } + } + private final int zero = 0; + @java.lang.SuppressWarnings("all") BuilderAndDataWithSetterPrefix() { + super(); + } + public static @java.lang.SuppressWarnings("all") BuilderAndDataWithSetterPrefixBuilder builder() { + return new BuilderAndDataWithSetterPrefixBuilder(); + } + public @java.lang.SuppressWarnings("all") int getZero() { + return this.zero; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { + if ((o == this)) + return true; + if ((! (o instanceof BuilderAndDataWithSetterPrefix))) + return false; + final BuilderAndDataWithSetterPrefix other = (BuilderAndDataWithSetterPrefix) o; + if ((! other.canEqual((java.lang.Object) this))) + return false; + if ((this.getZero() != other.getZero())) + return false; + return true; + } + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + return (other instanceof BuilderAndDataWithSetterPrefix); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 59; + int result = 1; + result = ((result * PRIME) + this.getZero()); + return result; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("BuilderAndDataWithSetterPrefix(zero=" + this.getZero()) + ")"); + } +} diff --git a/test/transform/resource/after-ecj/BuilderWithAccessorsWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithAccessorsWithSetterPrefix.java new file mode 100644 index 0000000000..d9c10e5bbc --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithAccessorsWithSetterPrefix.java @@ -0,0 +1,47 @@ +@lombok.Builder(setterPrefix = "with") @lombok.experimental.Accessors(prefix = {"p", "_"}) class BuilderWithAccessorsWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderWithAccessorsWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") int plower; + private @java.lang.SuppressWarnings("all") int upper; + private @java.lang.SuppressWarnings("all") int foo; + private @java.lang.SuppressWarnings("all") int _bar; + @java.lang.SuppressWarnings("all") BuilderWithAccessorsWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderWithAccessorsWithSetterPrefixBuilder withPlower(final int plower) { + this.plower = plower; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithAccessorsWithSetterPrefixBuilder withUpper(final int upper) { + this.upper = upper; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithAccessorsWithSetterPrefixBuilder withFoo(final int foo) { + this.foo = foo; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithAccessorsWithSetterPrefixBuilder with_bar(final int _bar) { + this._bar = _bar; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithAccessorsWithSetterPrefix build() { + return new BuilderWithAccessorsWithSetterPrefix(plower, upper, foo, _bar); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((((("BuilderWithAccessorsWithSetterPrefix.BuilderWithAccessorsWithSetterPrefixBuilder(plower=" + this.plower) + ", upper=") + this.upper) + ", foo=") + this.foo) + ", _bar=") + this._bar) + ")"); + } + } + private final int plower; + private final int pUpper; + private int _foo; + private int __bar; + @java.lang.SuppressWarnings("all") BuilderWithAccessorsWithSetterPrefix(final int plower, final int upper, final int foo, final int _bar) { + super(); + this.plower = plower; + this.pUpper = upper; + this._foo = foo; + this.__bar = _bar; + } + public static @java.lang.SuppressWarnings("all") BuilderWithAccessorsWithSetterPrefixBuilder builder() { + return new BuilderWithAccessorsWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderWithBadNamesWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithBadNamesWithSetterPrefix.java new file mode 100644 index 0000000000..248c77ad32 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithBadNamesWithSetterPrefix.java @@ -0,0 +1,33 @@ +public @lombok.Builder(setterPrefix = "with") class BuilderWithBadNamesWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderWithBadNamesWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") String build; + private @java.lang.SuppressWarnings("all") String toString; + @java.lang.SuppressWarnings("all") BuilderWithBadNamesWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderWithBadNamesWithSetterPrefixBuilder withBuild(final String build) { + this.build = build; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithBadNamesWithSetterPrefixBuilder withToString(final String toString) { + this.toString = toString; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithBadNamesWithSetterPrefix build() { + return new BuilderWithBadNamesWithSetterPrefix(build, toString); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((("BuilderWithBadNamesWithSetterPrefix.BuilderWithBadNamesWithSetterPrefixBuilder(build=" + this.build) + ", toString=") + this.toString) + ")"); + } + } + String build; + String toString; + @java.lang.SuppressWarnings("all") BuilderWithBadNamesWithSetterPrefix(final String build, final String toString) { + super(); + this.build = build; + this.toString = toString; + } + public static @java.lang.SuppressWarnings("all") BuilderWithBadNamesWithSetterPrefixBuilder builder() { + return new BuilderWithBadNamesWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderWithDeprecatedWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithDeprecatedWithSetterPrefix.java new file mode 100644 index 0000000000..83fa2e4e9d --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithDeprecatedWithSetterPrefix.java @@ -0,0 +1,87 @@ +import com.google.common.collect.ImmutableList; +import lombok.Builder; +import lombok.Singular; +public @Builder(setterPrefix = "with") class BuilderWithDeprecatedWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderWithDeprecatedWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") String dep1; + private @java.lang.SuppressWarnings("all") int dep2; + private @java.lang.SuppressWarnings("all") java.util.ArrayList strings; + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableList.Builder numbers; + @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefixBuilder() { + super(); + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefixBuilder withDep1(final String dep1) { + this.dep1 = dep1; + return this; + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefixBuilder withDep2(final int dep2) { + this.dep2 = dep2; + return this; + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefixBuilder withString(final String string) { + if ((this.strings == null)) + this.strings = new java.util.ArrayList(); + this.strings.add(string); + return this; + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefixBuilder withStrings(final java.util.Collection strings) { + if ((this.strings == null)) + this.strings = new java.util.ArrayList(); + this.strings.addAll(strings); + return this; + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefixBuilder clearStrings() { + if ((this.strings != null)) + this.strings.clear(); + return this; + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefixBuilder withNumber(final Integer number) { + if ((this.numbers == null)) + this.numbers = com.google.common.collect.ImmutableList.builder(); + this.numbers.add(number); + return this; + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefixBuilder withNumbers(final java.lang.Iterable numbers) { + if ((this.numbers == null)) + this.numbers = com.google.common.collect.ImmutableList.builder(); + this.numbers.addAll(numbers); + return this; + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefixBuilder clearNumbers() { + this.numbers = null; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefix build() { + java.util.List strings; + switch (((this.strings == null) ? 0 : this.strings.size())) { + case 0 : + strings = java.util.Collections.emptyList(); + break; + case 1 : + strings = java.util.Collections.singletonList(this.strings.get(0)); + break; + default : + strings = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.strings)); + } + com.google.common.collect.ImmutableList numbers = ((this.numbers == null) ? com.google.common.collect.ImmutableList.of() : this.numbers.build()); + return new BuilderWithDeprecatedWithSetterPrefix(dep1, dep2, strings, numbers); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((((("BuilderWithDeprecatedWithSetterPrefix.BuilderWithDeprecatedWithSetterPrefixBuilder(dep1=" + this.dep1) + ", dep2=") + this.dep2) + ", strings=") + this.strings) + ", numbers=") + this.numbers) + ")"); + } + } + String dep1; + @Deprecated int dep2; + @Singular @Deprecated java.util.List strings; + @Singular @Deprecated ImmutableList numbers; + @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefix(final String dep1, final int dep2, final java.util.List strings, final ImmutableList numbers) { + super(); + this.dep1 = dep1; + this.dep2 = dep2; + this.strings = strings; + this.numbers = numbers; + } + public static @java.lang.SuppressWarnings("all") BuilderWithDeprecatedWithSetterPrefixBuilder builder() { + return new BuilderWithDeprecatedWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderWithExistingBuilderClassWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithExistingBuilderClassWithSetterPrefix.java new file mode 100644 index 0000000000..8da2f012e7 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithExistingBuilderClassWithSetterPrefix.java @@ -0,0 +1,36 @@ +import lombok.Builder; +class BuilderWithExistingBuilderClassWithSetterPrefix { + public static class BuilderWithExistingBuilderClassWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") boolean arg2; + private @java.lang.SuppressWarnings("all") String arg3; + private Z arg1; + public void withArg2(boolean arg) { + } + @java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClassWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClassWithSetterPrefixBuilder withArg1(final Z arg1) { + this.arg1 = arg1; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClassWithSetterPrefixBuilder withArg3(final String arg3) { + this.arg3 = arg3; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClassWithSetterPrefix build() { + return BuilderWithExistingBuilderClassWithSetterPrefix.staticMethod(arg1, arg2, arg3); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((("BuilderWithExistingBuilderClassWithSetterPrefix.BuilderWithExistingBuilderClassWithSetterPrefixBuilder(arg1=" + this.arg1) + ", arg2=") + this.arg2) + ", arg3=") + this.arg3) + ")"); + } + } + BuilderWithExistingBuilderClassWithSetterPrefix() { + super(); + } + public static @Builder(setterPrefix = "with") BuilderWithExistingBuilderClassWithSetterPrefix staticMethod(Z arg1, boolean arg2, String arg3) { + return null; + } + public static @java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClassWithSetterPrefixBuilder builder() { + return new BuilderWithExistingBuilderClassWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderWithNoBuilderMethodWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithNoBuilderMethodWithSetterPrefix.java new file mode 100644 index 0000000000..30043dd9c7 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithNoBuilderMethodWithSetterPrefix.java @@ -0,0 +1,27 @@ +import lombok.Builder; +@Builder(toBuilder = true,builderMethodName = "",setterPrefix = "with") class BuilderWithNoBuilderMethodWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderWithNoBuilderMethodWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") String a; + @java.lang.SuppressWarnings("all") BuilderWithNoBuilderMethodWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderWithNoBuilderMethodWithSetterPrefixBuilder withA(final String a) { + this.a = a; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithNoBuilderMethodWithSetterPrefix build() { + return new BuilderWithNoBuilderMethodWithSetterPrefix(a); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("BuilderWithNoBuilderMethodWithSetterPrefix.BuilderWithNoBuilderMethodWithSetterPrefixBuilder(a=" + this.a) + ")"); + } + } + private String a = ""; + @java.lang.SuppressWarnings("all") BuilderWithNoBuilderMethodWithSetterPrefix(final String a) { + super(); + this.a = a; + } + public @java.lang.SuppressWarnings("all") BuilderWithNoBuilderMethodWithSetterPrefixBuilder toBuilder() { + return new BuilderWithNoBuilderMethodWithSetterPrefixBuilder().withA(this.a); + } +} diff --git a/test/transform/resource/after-ecj/BuilderWithNonNullWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithNonNullWithSetterPrefix.java new file mode 100644 index 0000000000..7f8cb80b8a --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithNonNullWithSetterPrefix.java @@ -0,0 +1,34 @@ +@lombok.Builder(setterPrefix = "with") class BuilderWithNonNullWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderWithNonNullWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") String id; + @java.lang.SuppressWarnings("all") BuilderWithNonNullWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderWithNonNullWithSetterPrefixBuilder withId(final @lombok.NonNull String id) { + if ((id == null)) + { + throw new java.lang.NullPointerException("id is marked non-null but is null"); + } + this.id = id; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithNonNullWithSetterPrefix build() { + return new BuilderWithNonNullWithSetterPrefix(id); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("BuilderWithNonNullWithSetterPrefix.BuilderWithNonNullWithSetterPrefixBuilder(id=" + this.id) + ")"); + } + } + private final @lombok.NonNull String id; + @java.lang.SuppressWarnings("all") BuilderWithNonNullWithSetterPrefix(final @lombok.NonNull String id) { + super(); + if ((id == null)) + { + throw new java.lang.NullPointerException("id is marked non-null but is null"); + } + this.id = id; + } + public static @java.lang.SuppressWarnings("all") BuilderWithNonNullWithSetterPrefixBuilder builder() { + return new BuilderWithNonNullWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderWithRecursiveGenericsWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithRecursiveGenericsWithSetterPrefix.java new file mode 100644 index 0000000000..7c5b191d57 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithRecursiveGenericsWithSetterPrefix.java @@ -0,0 +1,78 @@ +import java.util.Set; +import lombok.Builder; +import lombok.Value; +public class BuilderWithRecursiveGenericsWithSetterPrefix { + interface Inter> { + } + public static final @Builder(setterPrefix = "with") @Value class Test, Quz extends Inter> { + public static @java.lang.SuppressWarnings("all") class TestBuilder, Quz extends Inter> { + private @java.lang.SuppressWarnings("all") Foo foo; + private @java.lang.SuppressWarnings("all") Bar bar; + @java.lang.SuppressWarnings("all") TestBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") TestBuilder withFoo(final Foo foo) { + this.foo = foo; + return this; + } + public @java.lang.SuppressWarnings("all") TestBuilder withBar(final Bar bar) { + this.bar = bar; + return this; + } + public @java.lang.SuppressWarnings("all") Test build() { + return new Test(foo, bar); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((("BuilderWithRecursiveGenericsWithSetterPrefix.Test.TestBuilder(foo=" + this.foo) + ", bar=") + this.bar) + ")"); + } + } + private final Foo foo; + private final Bar bar; + @java.lang.SuppressWarnings("all") Test(final Foo foo, final Bar bar) { + super(); + this.foo = foo; + this.bar = bar; + } + public static @java.lang.SuppressWarnings("all") , Quz extends Inter>TestBuilder builder() { + return new TestBuilder(); + } + public @java.lang.SuppressWarnings("all") Foo getFoo() { + return this.foo; + } + public @java.lang.SuppressWarnings("all") Bar getBar() { + return this.bar; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { + if ((o == this)) + return true; + if ((! (o instanceof BuilderWithRecursiveGenericsWithSetterPrefix.Test))) + return false; + final BuilderWithRecursiveGenericsWithSetterPrefix.Test other = (BuilderWithRecursiveGenericsWithSetterPrefix.Test) o; + final java.lang.Object this$foo = this.getFoo(); + final java.lang.Object other$foo = other.getFoo(); + if (((this$foo == null) ? (other$foo != null) : (! this$foo.equals(other$foo)))) + return false; + final java.lang.Object this$bar = this.getBar(); + final java.lang.Object other$bar = other.getBar(); + if (((this$bar == null) ? (other$bar != null) : (! this$bar.equals(other$bar)))) + return false; + return true; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 59; + int result = 1; + final java.lang.Object $foo = this.getFoo(); + result = ((result * PRIME) + (($foo == null) ? 43 : $foo.hashCode())); + final java.lang.Object $bar = this.getBar(); + result = ((result * PRIME) + (($bar == null) ? 43 : $bar.hashCode())); + return result; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((("BuilderWithRecursiveGenericsWithSetterPrefix.Test(foo=" + this.getFoo()) + ", bar=") + this.getBar()) + ")"); + } + } + public BuilderWithRecursiveGenericsWithSetterPrefix() { + super(); + } +} + diff --git a/test/transform/resource/after-ecj/BuilderWithToBuilderWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithToBuilderWithSetterPrefix.java new file mode 100644 index 0000000000..6f3906d90a --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithToBuilderWithSetterPrefix.java @@ -0,0 +1,124 @@ +import java.util.List; +import lombok.Builder; +@Builder(toBuilder = true,setterPrefix = "with") @lombok.experimental.Accessors(prefix = "m") class BuilderWithToBuilderWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class BuilderWithToBuilderWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") String one; + private @java.lang.SuppressWarnings("all") String two; + private @java.lang.SuppressWarnings("all") T foo; + private @java.lang.SuppressWarnings("all") java.util.ArrayList bars; + @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefixBuilder withOne(final String one) { + this.one = one; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefixBuilder withTwo(final String two) { + this.two = two; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefixBuilder withFoo(final T foo) { + this.foo = foo; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefixBuilder withBar(final T bar) { + if ((this.bars == null)) + this.bars = new java.util.ArrayList(); + this.bars.add(bar); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefixBuilder withBars(final java.util.Collection bars) { + if ((this.bars == null)) + this.bars = new java.util.ArrayList(); + this.bars.addAll(bars); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefixBuilder clearBars() { + if ((this.bars != null)) + this.bars.clear(); + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefix build() { + java.util.List bars; + switch (((this.bars == null) ? 0 : this.bars.size())) { + case 0 : + bars = java.util.Collections.emptyList(); + break; + case 1 : + bars = java.util.Collections.singletonList(this.bars.get(0)); + break; + default : + bars = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.bars)); + } + return new BuilderWithToBuilderWithSetterPrefix(one, two, foo, bars); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((((("BuilderWithToBuilderWithSetterPrefix.BuilderWithToBuilderWithSetterPrefixBuilder(one=" + this.one) + ", two=") + this.two) + ", foo=") + this.foo) + ", bars=") + this.bars) + ")"); + } + } + private String mOne; + private String mTwo; + private @Builder.ObtainVia(method = "rrr",isStatic = true) T foo; + private @lombok.Singular List bars; + public static K rrr(BuilderWithToBuilderWithSetterPrefix x) { + return x.foo; + } + @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefix(final String one, final String two, final T foo, final List bars) { + super(); + this.mOne = one; + this.mTwo = two; + this.foo = foo; + this.bars = bars; + } + public static @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefixBuilder builder() { + return new BuilderWithToBuilderWithSetterPrefixBuilder(); + } + public @java.lang.SuppressWarnings("all") BuilderWithToBuilderWithSetterPrefixBuilder toBuilder() { + final BuilderWithToBuilderWithSetterPrefixBuilder builder = new BuilderWithToBuilderWithSetterPrefixBuilder().withOne(this.mOne).withTwo(this.mTwo).withFoo(BuilderWithToBuilderWithSetterPrefix.rrr(this)); + if ((this.bars != null)) + builder.withBars(this.bars); + return builder; + } +} + +@lombok.experimental.Accessors(prefix = "m") class ConstructorWithToBuilderWithSetterPrefix { + public static @java.lang.SuppressWarnings("all") class ConstructorWithToBuilderWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") String mOne; + private @java.lang.SuppressWarnings("all") T baz; + private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableList bars; + @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder withMOne(final String mOne) { + this.mOne = mOne; + return this; + } + public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder withBaz(final T baz) { + this.baz = baz; + return this; + } + public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder withBars(final com.google.common.collect.ImmutableList bars) { + this.bars = bars; + return this; + } + public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefix build() { + return new ConstructorWithToBuilderWithSetterPrefix(mOne, baz, bars); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + 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 bars; + public @Builder(toBuilder = true,setterPrefix = "with") ConstructorWithToBuilderWithSetterPrefix(String mOne, @Builder.ObtainVia(field = "foo") T baz, com.google.common.collect.ImmutableList bars) { + super(); + } + public static @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder builder() { + return new ConstructorWithToBuilderWithSetterPrefixBuilder(); + } + public @java.lang.SuppressWarnings("all") ConstructorWithToBuilderWithSetterPrefixBuilder toBuilder() { + return new ConstructorWithToBuilderWithSetterPrefixBuilder().withMOne(this.mOne).withBaz(this.foo).withBars(this.bars); + } +} diff --git a/test/transform/resource/after-ecj/BuilderWithTolerateWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithTolerateWithSetterPrefix.java new file mode 100644 index 0000000000..6fa302e52b --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithTolerateWithSetterPrefix.java @@ -0,0 +1,34 @@ +import lombok.Builder; +import lombok.experimental.Tolerate; +public @Builder(setterPrefix = "with") class BuilderWithTolerateWithSetterPrefix { + public static class BuilderWithTolerateWithSetterPrefixBuilder { + private @java.lang.SuppressWarnings("all") int value; + public @Tolerate BuilderWithTolerateWithSetterPrefixBuilder withValue(String s) { + return this.withValue(Integer.parseInt(s)); + } + @java.lang.SuppressWarnings("all") BuilderWithTolerateWithSetterPrefixBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderWithTolerateWithSetterPrefixBuilder withValue(final int value) { + this.value = value; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithTolerateWithSetterPrefix build() { + return new BuilderWithTolerateWithSetterPrefix(value); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("BuilderWithTolerateWithSetterPrefix.BuilderWithTolerateWithSetterPrefixBuilder(value=" + this.value) + ")"); + } + } + private final int value; + public static void main(String[] args) { + BuilderWithTolerateWithSetterPrefix.builder().withValue("42").build(); + } + @java.lang.SuppressWarnings("all") BuilderWithTolerateWithSetterPrefix(final int value) { + super(); + this.value = value; + } + public static @java.lang.SuppressWarnings("all") BuilderWithTolerateWithSetterPrefixBuilder builder() { + return new BuilderWithTolerateWithSetterPrefixBuilder(); + } +} diff --git a/test/transform/resource/before/BuilderSimpleWithSetterPrefix.java b/test/transform/resource/before/BuilderSimpleWithSetterPrefix.java new file mode 100644 index 0000000000..19ab7af10f --- /dev/null +++ b/test/transform/resource/before/BuilderSimpleWithSetterPrefix.java @@ -0,0 +1,6 @@ +import java.util.List; + +@lombok.Builder(access = lombok.AccessLevel.PROTECTED, setterPrefix = "with") +class BuilderSimpleWithSetterPrefix { + private int unprefixed; +} diff --git a/test/transform/resource/before/BuilderSingularAnnotatedTypesWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularAnnotatedTypesWithSetterPrefix.java new file mode 100644 index 0000000000..ef8cb2e3e2 --- /dev/null +++ b/test/transform/resource/before/BuilderSingularAnnotatedTypesWithSetterPrefix.java @@ -0,0 +1,14 @@ +//VERSION 8: +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.util.Set; +import java.util.Map; +import lombok.NonNull; +import lombok.Singular; +@Target(ElementType.TYPE_USE) +@interface MyAnnotation {} +@lombok.Builder(setterPrefix = "with") +class BuilderSingularAnnotatedTypesWithSetterPrefix { + @Singular private Set<@MyAnnotation @NonNull String> foos; + @Singular private Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars; +} diff --git a/test/transform/resource/before/BuilderSingularGuavaListsSetsWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularGuavaListsSetsWithSetterPrefix.java new file mode 100644 index 0000000000..af02adb6d3 --- /dev/null +++ b/test/transform/resource/before/BuilderSingularGuavaListsSetsWithSetterPrefix.java @@ -0,0 +1,16 @@ +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; + +import lombok.Singular; + +@lombok.Builder(setterPrefix = "with") +class BuilderSingularGuavaListsSetsWithSetterPrefix { + @Singular private ImmutableList cards; + @Singular private ImmutableCollection frogs; + @SuppressWarnings("all") @Singular("rawSet") private ImmutableSet rawSet; + @Singular private ImmutableSortedSet passes; + @Singular private ImmutableTable users; +} diff --git a/test/transform/resource/before/BuilderSingularGuavaMapsWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularGuavaMapsWithSetterPrefix.java new file mode 100644 index 0000000000..a2b48cb39d --- /dev/null +++ b/test/transform/resource/before/BuilderSingularGuavaMapsWithSetterPrefix.java @@ -0,0 +1,12 @@ +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableBiMap; +import com.google.common.collect.ImmutableSortedMap; + +import lombok.Singular; + +@lombok.Builder(setterPrefix = "with") +class BuilderSingularGuavaMapsWithSetterPrefix { + @Singular private ImmutableMap battleaxes; + @Singular private ImmutableSortedMap vertices; + @SuppressWarnings("all") @Singular("rawMap") private ImmutableBiMap rawMap; +} diff --git a/test/transform/resource/before/BuilderSingularListsWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularListsWithSetterPrefix.java new file mode 100644 index 0000000000..fd53d97fa8 --- /dev/null +++ b/test/transform/resource/before/BuilderSingularListsWithSetterPrefix.java @@ -0,0 +1,11 @@ +import java.util.List; +import java.util.Collection; + +import lombok.Singular; + +@lombok.Builder(setterPrefix = "with") +class BuilderSingularListsWithSetterPrefix { + @Singular private List children; + @Singular private Collection scarves; + @SuppressWarnings("all") @Singular("rawList") private List rawList; +} diff --git a/test/transform/resource/before/BuilderSingularMapsWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularMapsWithSetterPrefix.java new file mode 100644 index 0000000000..728ad59aeb --- /dev/null +++ b/test/transform/resource/before/BuilderSingularMapsWithSetterPrefix.java @@ -0,0 +1,15 @@ +//FORMAT: javaLangAsFQN = skip +//FORMAT: generated = skip +//FORMAT: finalParams = skip +import java.util.Map; +import java.util.SortedMap; + +import lombok.Singular; + +@lombok.Builder(setterPrefix = "with") +class BuilderSingularMapsWithSetterPrefix { + @Singular private Map women; + @Singular private SortedMap men; + @SuppressWarnings("all") @Singular("rawMap") private Map rawMap; + @Singular("stringMap") private Map stringMap; +} diff --git a/test/transform/resource/before/BuilderSingularNoAutoWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularNoAutoWithSetterPrefix.java new file mode 100644 index 0000000000..fa55c553f0 --- /dev/null +++ b/test/transform/resource/before/BuilderSingularNoAutoWithSetterPrefix.java @@ -0,0 +1,11 @@ +//CONF: lombok.singular.auto = false +import java.util.List; + +import lombok.Singular; + +@lombok.Builder(setterPrefix = "with") +class BuilderSingularNoAutoWithSetterPrefix { + @Singular private List things; + @Singular("widget") private List widgets; + @Singular private List items; +} diff --git a/test/transform/resource/before/BuilderSingularRedirectToGuavaWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularRedirectToGuavaWithSetterPrefix.java new file mode 100644 index 0000000000..7281141dd7 --- /dev/null +++ b/test/transform/resource/before/BuilderSingularRedirectToGuavaWithSetterPrefix.java @@ -0,0 +1,13 @@ +//CONF: lombok.singular.useGuava = true +import java.util.Set; +import java.util.NavigableMap; +import java.util.Collection; + +import lombok.Singular; + +@lombok.Builder(setterPrefix = "with") +class BuilderSingularRedirectToGuavaWithSetterPrefix { + @Singular private Set dangerMice; + @Singular private NavigableMap things; + @Singular private Collection> doohickeys; +} diff --git a/test/transform/resource/before/BuilderSingularSetsWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularSetsWithSetterPrefix.java new file mode 100644 index 0000000000..d28241091c --- /dev/null +++ b/test/transform/resource/before/BuilderSingularSetsWithSetterPrefix.java @@ -0,0 +1,12 @@ +import java.util.Set; +import java.util.SortedSet; + +import lombok.Singular; + +@lombok.Builder(setterPrefix = "with") +class BuilderSingularSetsWithSetterPrefix { + @Singular private Set dangerMice; + @Singular private SortedSet octopodes; + @SuppressWarnings("all") @Singular("rawSet") private Set rawSet; + @Singular("stringSet") private Set stringSet; +} diff --git a/test/transform/resource/before/BuilderSingularToBuilderWithNullWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularToBuilderWithNullWithSetterPrefix.java new file mode 100644 index 0000000000..454cac97dd --- /dev/null +++ b/test/transform/resource/before/BuilderSingularToBuilderWithNullWithSetterPrefix.java @@ -0,0 +1,10 @@ +import lombok.Singular; + +@lombok.Builder(toBuilder = true, setterPrefix = "with") +class BuilderSingularToBuilderWithNullWithSetterPrefix { + @Singular private java.util.List elems; + + public static void test() { + new BuilderSingularToBuilderWithNullWithSetterPrefix(null).toBuilder(); + } +} diff --git a/test/transform/resource/before/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java new file mode 100644 index 0000000000..cea10babd3 --- /dev/null +++ b/test/transform/resource/before/BuilderSingularWildcardListsWithToBuilderWithSetterPrefix.java @@ -0,0 +1,10 @@ +import java.util.List; +import java.util.Collection; + +import lombok.Singular; + +@lombok.Builder(toBuilder = true, setterPrefix = "with") +class BuilderSingularWildcardListsWithToBuilderWithSetterPrefix { + @Singular private List objects; + @Singular private Collection numbers; +} diff --git a/test/transform/resource/before/BuilderSingularWithPrefixesWithSetterPrefix.java b/test/transform/resource/before/BuilderSingularWithPrefixesWithSetterPrefix.java new file mode 100644 index 0000000000..1b95366888 --- /dev/null +++ b/test/transform/resource/before/BuilderSingularWithPrefixesWithSetterPrefix.java @@ -0,0 +1,7 @@ +import lombok.Singular; + +@lombok.Builder(setterPrefix = "with") +@lombok.experimental.Accessors(prefix = "_") +class BuilderSingularWithPrefixesWithSetterPrefix { + @Singular private java.util.List _elems; +} diff --git a/test/transform/resource/before/BuilderTypeAnnosWithSetterPrefix.java b/test/transform/resource/before/BuilderTypeAnnosWithSetterPrefix.java new file mode 100644 index 0000000000..4adde2a0e1 --- /dev/null +++ b/test/transform/resource/before/BuilderTypeAnnosWithSetterPrefix.java @@ -0,0 +1,14 @@ +//CONF: lombok.copyableAnnotations += TA +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.util.List; +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +@interface TA { +} +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +@interface TB { +} +@lombok.Builder(setterPrefix = "with") +class BuilderTypeAnnosWithSetterPrefix { + private @TA @TB List foo; +} diff --git a/test/transform/resource/before/BuilderValueDataWithSetterPrefix.java b/test/transform/resource/before/BuilderValueDataWithSetterPrefix.java new file mode 100644 index 0000000000..530c24d262 --- /dev/null +++ b/test/transform/resource/before/BuilderValueDataWithSetterPrefix.java @@ -0,0 +1,11 @@ +import java.util.List; + +@lombok.Builder(setterPrefix = "with") @lombok.Value +class BuilderAndValueWithSetterPrefix { + private final int zero = 0; +} + +@lombok.Builder(setterPrefix = "with") @lombok.Data +class BuilderAndDataWithSetterPrefix { + private final int zero = 0; +} diff --git a/test/transform/resource/before/BuilderWithAccessorsWithSetterPrefix.java b/test/transform/resource/before/BuilderWithAccessorsWithSetterPrefix.java new file mode 100644 index 0000000000..4f4ebb1876 --- /dev/null +++ b/test/transform/resource/before/BuilderWithAccessorsWithSetterPrefix.java @@ -0,0 +1,7 @@ +@lombok.Builder(setterPrefix = "with") @lombok.experimental.Accessors(prefix={"p", "_"}) +class BuilderWithAccessorsWithSetterPrefix { + private final int plower; + private final int pUpper; + private int _foo; + private int __bar; +} diff --git a/test/transform/resource/before/BuilderWithBadNamesWithSetterPrefix.java b/test/transform/resource/before/BuilderWithBadNamesWithSetterPrefix.java new file mode 100644 index 0000000000..69322ee3c0 --- /dev/null +++ b/test/transform/resource/before/BuilderWithBadNamesWithSetterPrefix.java @@ -0,0 +1,5 @@ +@lombok.Builder(setterPrefix = "with") +public class BuilderWithBadNamesWithSetterPrefix { + String build; + String toString; +} diff --git a/test/transform/resource/before/BuilderWithDeprecatedWithSetterPrefix.java b/test/transform/resource/before/BuilderWithDeprecatedWithSetterPrefix.java new file mode 100644 index 0000000000..77baccd390 --- /dev/null +++ b/test/transform/resource/before/BuilderWithDeprecatedWithSetterPrefix.java @@ -0,0 +1,11 @@ +import com.google.common.collect.ImmutableList; +import lombok.Builder; +import lombok.Singular; + +@Builder(setterPrefix = "with") +public class BuilderWithDeprecatedWithSetterPrefix { + /** @deprecated since always */ String dep1; + @Deprecated int dep2; + @Singular @Deprecated java.util.List strings; + @Singular @Deprecated ImmutableList numbers; +} diff --git a/test/transform/resource/before/BuilderWithExistingBuilderClassWithSetterPrefix.java b/test/transform/resource/before/BuilderWithExistingBuilderClassWithSetterPrefix.java new file mode 100644 index 0000000000..e30dd1fff2 --- /dev/null +++ b/test/transform/resource/before/BuilderWithExistingBuilderClassWithSetterPrefix.java @@ -0,0 +1,15 @@ +import lombok.Builder; + +class BuilderWithExistingBuilderClassWithSetterPrefix { + @Builder(setterPrefix = "with") + public static BuilderWithExistingBuilderClassWithSetterPrefix staticMethod(Z arg1, boolean arg2, String arg3) { + return null; + } + + public static class BuilderWithExistingBuilderClassWithSetterPrefixBuilder { + private Z arg1; + + public void withArg2(boolean arg) { + } + } +} diff --git a/test/transform/resource/before/BuilderWithNoBuilderMethodWithSetterPrefix.java b/test/transform/resource/before/BuilderWithNoBuilderMethodWithSetterPrefix.java new file mode 100644 index 0000000000..80197dd361 --- /dev/null +++ b/test/transform/resource/before/BuilderWithNoBuilderMethodWithSetterPrefix.java @@ -0,0 +1,5 @@ +import lombok.Builder; +@Builder(toBuilder = true, builderMethodName = "",setterPrefix = "with") +class BuilderWithNoBuilderMethodWithSetterPrefix { + private String a = ""; +} diff --git a/test/transform/resource/before/BuilderWithNonNullWithSetterPrefix.java b/test/transform/resource/before/BuilderWithNonNullWithSetterPrefix.java new file mode 100644 index 0000000000..8ef1f70eb5 --- /dev/null +++ b/test/transform/resource/before/BuilderWithNonNullWithSetterPrefix.java @@ -0,0 +1,5 @@ +@lombok.Builder(setterPrefix = "with") +class BuilderWithNonNullWithSetterPrefix { + @lombok.NonNull + private final String id; +} diff --git a/test/transform/resource/before/BuilderWithRecursiveGenericsWithSetterPrefix.java b/test/transform/resource/before/BuilderWithRecursiveGenericsWithSetterPrefix.java new file mode 100644 index 0000000000..ce8803c094 --- /dev/null +++ b/test/transform/resource/before/BuilderWithRecursiveGenericsWithSetterPrefix.java @@ -0,0 +1,13 @@ +//issue #1298 +import java.util.Set; +import lombok.Builder; +import lombok.Value; + +public class BuilderWithRecursiveGenericsWithSetterPrefix { + interface Inter> {} + + @Builder(setterPrefix = "with") @Value public static class Test, Quz extends Inter> { + Foo foo; + Bar bar; + } +} diff --git a/test/transform/resource/before/BuilderWithToBuilderWithSetterPrefix.java b/test/transform/resource/before/BuilderWithToBuilderWithSetterPrefix.java new file mode 100644 index 0000000000..3b442b8d20 --- /dev/null +++ b/test/transform/resource/before/BuilderWithToBuilderWithSetterPrefix.java @@ -0,0 +1,20 @@ +import java.util.List; +import lombok.Builder; +@Builder(toBuilder = true, setterPrefix = "with") @lombok.experimental.Accessors(prefix = "m") +class BuilderWithToBuilderWithSetterPrefix { + private String mOne, mTwo; + @Builder.ObtainVia(method = "rrr", isStatic = true) private T foo; + @lombok.Singular private List bars; + public static K rrr(BuilderWithToBuilderWithSetterPrefix x) { + return x.foo; + } +} +@lombok.experimental.Accessors(prefix = "m") +class ConstructorWithToBuilderWithSetterPrefix { + private String mOne, mTwo; + private T foo; + @lombok.Singular private com.google.common.collect.ImmutableList bars; + @Builder(toBuilder = true, setterPrefix = "with") + public ConstructorWithToBuilderWithSetterPrefix(String mOne, @Builder.ObtainVia(field = "foo") T baz, com.google.common.collect.ImmutableList bars) { + } +} diff --git a/test/transform/resource/before/BuilderWithTolerateWithSetterPrefix.java b/test/transform/resource/before/BuilderWithTolerateWithSetterPrefix.java new file mode 100644 index 0000000000..5c77e17742 --- /dev/null +++ b/test/transform/resource/before/BuilderWithTolerateWithSetterPrefix.java @@ -0,0 +1,18 @@ +import lombok.Builder; +import lombok.experimental.Tolerate; + +@Builder(setterPrefix = "with") +public class BuilderWithTolerateWithSetterPrefix { + private final int value; + + public static void main(String[] args) { + BuilderWithTolerateWithSetterPrefix.builder().withValue("42").build(); + } + + public static class BuilderWithTolerateWithSetterPrefixBuilder { + @Tolerate + public BuilderWithTolerateWithSetterPrefixBuilder withValue(String s) { + return this.withValue(Integer.parseInt(s)); + } + } +} diff --git a/test/transform/resource/messages-delombok/BuilderSingularNoAutoWithSetterPrefix.java.messages b/test/transform/resource/messages-delombok/BuilderSingularNoAutoWithSetterPrefix.java.messages new file mode 100644 index 0000000000..8719789b19 --- /dev/null +++ b/test/transform/resource/messages-delombok/BuilderSingularNoAutoWithSetterPrefix.java.messages @@ -0,0 +1,2 @@ +8 The singular must be specified explicitly (e.g. @Singular("task")) because auto singularization is disabled. +10 The singular must be specified explicitly (e.g. @Singular("task")) because auto singularization is disabled. diff --git a/test/transform/resource/messages-ecj/BuilderSingularNoAutoWithSetterPrefix.java.messages b/test/transform/resource/messages-ecj/BuilderSingularNoAutoWithSetterPrefix.java.messages new file mode 100644 index 0000000000..8719789b19 --- /dev/null +++ b/test/transform/resource/messages-ecj/BuilderSingularNoAutoWithSetterPrefix.java.messages @@ -0,0 +1,2 @@ +8 The singular must be specified explicitly (e.g. @Singular("task")) because auto singularization is disabled. +10 The singular must be specified explicitly (e.g. @Singular("task")) because auto singularization is disabled.