void (@NonNls String word, WordCase foundCase, StringBuilder result) { if (foundCase.upperCase && foundCase.lowerCase) { // no letters seen result.append(word); return; } WordCase replacementCase = analyze(word); if (foundCase.upperCase) { if (replacementCase.upperCase) { result.append(word); } else { result.append(word.toUpperCase(Locale.getDefault())); } } else { boolean prevIsWordChar = false; for (int i = 0, length = word.length(); i < length; i++) { final char c = word.charAt(i); if (Character.isLetter(c)) { if (!prevIsWordChar) { result.append(foundCase.lowerCase || !foundCase.capitalized ? StringUtil.toLowerCase(c) : StringUtil.toUpperCase(c)); prevIsWordChar = true; } else { result.append(replacementCase.upperCase ? StringUtil.toLowerCase(c) : c); } } else { prevIsWordChar = Character.isDigit(c); result.append(c); } } } }