This is the complement the behavior of the decapitalize(String) method. We handle names that begin with an initial lowerCase followed by upperCase with special JavaBean behavior (which is to make no change). See GROOVY-3211. @param property the property name to capitalize @return the name capitaliz
(final String property)
| 59 | * @since 3.0.0 |
| 60 | */ |
| 61 | public static String capitalize(final String property) { |
| 62 | int propertyLength = (property == null ? 0 : property.length()); |
| 63 | if (propertyLength == 0 || !Character.isLowerCase(property.charAt(0)) |
| 64 | || (propertyLength > 1 && Character.isUpperCase(property.charAt(1)))) { |
| 65 | return property; |
| 66 | } |
| 67 | final char[] c = property.toCharArray(); |
| 68 | c[0] = Character.toUpperCase(c[0]); |
| 69 | return new String(c); |
| 70 | } |
| 71 | |
| 72 | private BeanUtils() { |
| 73 | } |
no test coverage detected