String (@NotNull StringBuilder text) { if (text.length() <= MAX_TEXT_LENGTH) { return text.toString(); } int index; for (index = MAX_TEXT_LENGTH; index > MAX_TEXT_LENGTH - 20; index--) { if (!Character.isLetter(text.charAt(index))) { break; } } text.setLength(Character.isLetter(index) ? MAX_TEXT_LENGTH : index); return text.append("\u2026").toString(); }