class HibernateSimpleQueryUtils {

    static String replaceSubstring(Pair<Integer, Integer> startEndIndexPair, String stringToReplaceIn, String replacement) {
        var startIndex = startEndIndexPair.getFirst();
        var endIndex = startEndIndexPair.getSecond();

        var predReplaceSubstring = startIndex <= 1 ? "" : stringToReplaceIn.substring(0, startIndex);
        var succReplaceSubstring = endIndex >= (stringToReplaceIn.length() - 1) ? "" : stringToReplaceIn.substring(endIndex + 1);

        return String.format("%s%s%s", predReplaceSubstring, replacement, succReplaceSubstring);
    }

}