(String input)
| 201 | } |
| 202 | |
| 203 | public static String upperToDash(String input) { |
| 204 | StringBuilder result = new StringBuilder(); |
| 205 | for (int i = 0; i < input.length(); i++) { |
| 206 | char c = input.charAt(i); |
| 207 | if (Character.isUpperCase(c)) { |
| 208 | if (i == 0 || input.charAt(i - 1) == '_') { |
| 209 | result.append(Character.toLowerCase(c)); |
| 210 | } else { |
| 211 | result.append("_").append(Character.toLowerCase(c)); |
| 212 | } |
| 213 | } else { |
| 214 | result.append(c); |
| 215 | } |
| 216 | } |
| 217 | return result.toString(); |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Returns the closest value of a List to given Integer. |
no test coverage detected