From 1929a28c9def0dd276dcf3fdb70ada8b84b1c64a Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 17 Jun 2009 21:27:27 +0200 Subject: Added the SetterHandler for javac. Also added a way to get the SymbolTable on a JavacAST.Node, because you need it to e.g. access constant types like 'void'. --- src/lombok/core/TransformationsUtil.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/lombok/core') diff --git a/src/lombok/core/TransformationsUtil.java b/src/lombok/core/TransformationsUtil.java index 0ce99d9f..8aea09a4 100644 --- a/src/lombok/core/TransformationsUtil.java +++ b/src/lombok/core/TransformationsUtil.java @@ -5,14 +5,22 @@ public class TransformationsUtil { public static String toGetterName(CharSequence fieldName, boolean isBoolean) { final String prefix = isBoolean ? "is" : "get"; - final String suffix; if ( fieldName.length() == 0 ) return prefix; - char first = fieldName.charAt(0); + return buildName(prefix, fieldName.toString()); + } + + private static String buildName(String prefix, String suffix) { + if ( suffix.length() == 0 ) return prefix; + + char first = suffix.charAt(0); if ( Character.isLowerCase(first) ) - suffix = String.format("%s%s", Character.toTitleCase(first), fieldName.subSequence(1, fieldName.length())); - else suffix = fieldName.toString(); + suffix = String.format("%s%s", Character.toTitleCase(first), suffix.subSequence(1, suffix.length())); return String.format("%s%s", prefix, suffix); } + + public static String toSetterName(CharSequence fieldName) { + return buildName("set", fieldName.toString()); + } } -- cgit