diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2011-01-29 16:54:14 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2011-02-07 21:35:34 +0100 |
commit | c98cec7d2ddceddcc0f127185912be4f826a6caa (patch) | |
tree | dc8c50a3ac256a08faac8adde76904bca004cbd8 /src/core/lombok/javac/handlers/JavacHandlerUtil.java | |
parent | aab3faa3cb43b4a854b5d094f1ef80eb39543bfb (diff) | |
download | lombok-c98cec7d2ddceddcc0f127185912be4f826a6caa.tar.gz lombok-c98cec7d2ddceddcc0f127185912be4f826a6caa.tar.bz2 lombok-c98cec7d2ddceddcc0f127185912be4f826a6caa.zip |
Presence of isFoo(), hasFoo(), and getFoo(), as well as properties named 'isFoo', 'hasFoo', or 'getFoo' would trigger specialized handling for @Getter/@Setter. However, this special handling broke the bean spec, and has been simplified: Only fields named 'isFoo', and only if that field's type is 'boolean', results in both 'isFoo' and 'foo' being considered as possible property names for this property, with 'foo' preferred, so that @Getter boolean isFoo will generate setFoo and isFoo methods, not setIsFoo and isIsFoo.
Fixes issue #148
Diffstat (limited to 'src/core/lombok/javac/handlers/JavacHandlerUtil.java')
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index aa4e1bb2..1fb72dfa 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -159,6 +159,18 @@ public class JavacHandlerUtil { } /** + * Translates the given field into all possible setter names. + * Convenient wrapper around {@link TransformationsUtil#toAllSetterNames(CharSequence, boolean)}. + */ + public static java.util.List<String> toAllSetterNames(JCVariableDecl field) { + CharSequence fieldName = field.name; + + boolean isBoolean = field.vartype.toString().equals("boolean"); + + return TransformationsUtil.toAllSetterNames(fieldName, isBoolean); + } + + /** * @return the likely setter name for the stated field. (e.g. private boolean foo; to setFoo). * * Convenient wrapper around {@link TransformationsUtil#toSetterName(CharSequence)}. @@ -166,7 +178,9 @@ public class JavacHandlerUtil { public static String toSetterName(JCVariableDecl field) { CharSequence fieldName = field.name; - return TransformationsUtil.toSetterName(fieldName); + boolean isBoolean = field.vartype.toString().equals("boolean"); + + return TransformationsUtil.toSetterName(fieldName, isBoolean); } /** Serves as return value for the methods that check for the existence of fields and methods. */ |