String (@NotNull String text, char separator, @NotNull Function<? super String, String> transformWord) { final String[] words = NameUtilCore.nameToWords(text); boolean insertSeparator = false; final StringBuilder buf = new StringBuilder(); for (String word : words) { if (!Character.isLetterOrDigit(word.charAt(0))) { buf.append(separator); insertSeparator = false; continue; } if (insertSeparator) { buf.append(separator); } else { insertSeparator = true; } buf.append(transformWord.apply(word)); } return buf.toString(); }