String (@NotNull final String name) { StringBuilder buffer = new StringBuilder(); final int length = name.length(); for (int i = 0; i < length; i++) { final char ch = name.charAt(i); if (ch != '-') { buffer.append(Character.toLowerCase(ch)); } else { buffer.append("_"); } if (Character.isLetterOrDigit(ch)) { if (Character.isUpperCase(ch)) { if (i + 2 < length) { final char chNext = name.charAt(i + 1); final char chNextNext = name.charAt(i + 2); if (Character.isUpperCase(chNext) && Character.isLowerCase(chNextNext)) { buffer.append('_'); } } } else if (Character.isLowerCase(ch) || Character.isDigit(ch)) { if (i + 1 < length) { final char chNext = name.charAt(i + 1); if (Character.isUpperCase(chNext)) { buffer.append('_'); } } } } } return buffer.toString(); }