String (@NotNull String text, int maxLength, int suffixLength, @NotNull String symbol) { int textLength = text.length(); if (textLength > maxLength) { int prefixLength = maxLength - suffixLength - symbol.length(); assert prefixLength >= 0; return text.substring(0, prefixLength) + symbol + text.substring(textLength - suffixLength); } else { return text; } }