boolean (@NotNull CharSequence text, int start, int end, @NotNull CharSequence suffix) { if (start < 0 || end > text.length()) { throw new IllegalArgumentException("invalid offsets: start="+start+"; end="+end+"; text.length()="+text.length()); } int suffixLen = suffix.length(); int delta = end - suffixLen; if (delta < start) { return false; } for (int i = 0; i < suffixLen; i++) { if (text.charAt(delta + i) != suffix.charAt(i)) { return false; } } return true; }