Returns a string which is the same as the original except the first letter will be lowercase except for some special cases as per JavaBean handling. In particular, if the first two letters are both uppercase, e.g. URL, then no change of case occurs. Originally inspired by the method with the sam
(final String property)
| 38 | * @see <a href="https://stackoverflow.com/questions/4052840/most-efficient-way-to-make-the-first-character-of-a-string-lower-case/4052914">A relevant stack overflow question</a> |
| 39 | */ |
| 40 | public static String decapitalize(final String property) { |
| 41 | int propertyLength = (property == null ? 0 : property.length()); |
| 42 | if (propertyLength == 0 || !Character.isUpperCase(property.charAt(0)) |
| 43 | || (propertyLength > 1 && Character.isUpperCase(property.charAt(1)))) { |
| 44 | return property; |
| 45 | } |
| 46 | final char[] c = property.toCharArray(); |
| 47 | c[0] = Character.toLowerCase(c[0]); |
| 48 | return new String(c); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * This is the complement the behavior of the decapitalize(String) method. |
no test coverage detected