public static String capitalize(final String property) {
        final String rest = property.substring(1);

        // Funky rule so that names like 'pNAME' will still work.
        if (Character.isLowerCase(property.charAt(0)) && (rest.length() > 0) && isUpperCase(rest.charAt(0))) {
            return property;
        }

        return property.substring(0, 1).toUpperCase() + rest;
    }
public static String capitalize ( final String property ) { final String rest = property . substring ( 1 ) ; if ( Character . isLowerCase ( property . charAt ( 0 ) ) && ( rest . length ( ) > 0 ) && isUpperCase ( rest . charAt ( 0 ) ) ) { return property ; } return property . substring ( 0 , 1 ) . toUpperCase ( ) + rest ; }
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 capitalized, except when we don't