aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/core/TransformationsUtil.java
blob: 0ce99d9fdf55a0358cac291cffb97c3e2c5d27b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package lombok.core;

public class TransformationsUtil {
	private 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);
		if ( Character.isLowerCase(first) )
			suffix = String.format("%s%s", Character.toTitleCase(first), fieldName.subSequence(1, fieldName.length()));
		else suffix = fieldName.toString();
		return String.format("%s%s", prefix, suffix);
	}
}