diff options
author | Jan Rieke <it@janrieke.de> | 2018-04-10 22:28:08 +0200 |
---|---|---|
committer | Jan Rieke <it@janrieke.de> | 2018-04-10 22:37:21 +0200 |
commit | 9a3866ef52186bde47a698230ba9498df378768d (patch) | |
tree | 29d898d578343e5257f87de3ce8c90e1f48b893d /src/core/lombok/javac/handlers/JavacSingularsRecipes.java | |
parent | fdc23437e290b1b5d16d02d1d8927dc7dade3dcb (diff) | |
download | lombok-9a3866ef52186bde47a698230ba9498df378768d.tar.gz lombok-9a3866ef52186bde47a698230ba9498df378768d.tar.bz2 lombok-9a3866ef52186bde47a698230ba9498df378768d.zip |
correct return type and statement for @Singular
Diffstat (limited to 'src/core/lombok/javac/handlers/JavacSingularsRecipes.java')
-rw-r--r-- | src/core/lombok/javac/handlers/JavacSingularsRecipes.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java index 4279ec63..ea5d1a54 100644 --- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java +++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java @@ -194,7 +194,30 @@ public class JavacSingularsRecipes { } public abstract java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JCTree source); - public abstract void generateMethods(SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, boolean chain); + + /** + * Generates the singular, plural, and clear methods for the given + * {@link SingularData}.<br> + * Uses the given <code>builderType</code> as return type if + * <code>chain == true</code>, <code>void</code> otherwise.. If you need more + * control over the return type and value, use + * {@link #generateMethods(SingularData, boolean, JavacNode, JCTree, boolean, JCExpression, JCStatement)}. + */ + public void generateMethods(SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, boolean chain) { + JavacTreeMaker maker = builderType.getTreeMaker(); + JCExpression returnType = chain ? + cloneSelfType(builderType) : + maker.Type(createVoidType(builderType.getSymbolTable(), CTC_VOID)); + JCStatement returnStatement = chain ? maker.Return(maker.Ident(builderType.toName("this"))) : null; + generateMethods(data, deprecate, builderType, source, fluent, returnType, returnStatement); + } + /** + * Generates the singular, plural, and clear methods for the given + * {@link SingularData}.<br> + * Uses the given <code>returnType</code> and <code>returnStatement</code> for the generated methods. + */ + public abstract void generateMethods(SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, JCExpression returnType, JCStatement returnStatement); + public abstract void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable); public boolean requiresCleaning() { |