HibernateSimpleQueryUtils { static String replaceTermWithFuzzyAndPrefixDisjunction(Pair<Integer, Integer> startEndIndexPair, String simpleQuery) { var termStartIndex = startEndIndexPair.getFirst(); var termEndIndex = startEndIndexPair.getSecond(); var term = simpleQuery.substring(termStartIndex, termEndIndex + 1); var replaceTerm = String.format("(%s)", createLuceneQueryString(List.of(term, term + "~1", term + "*"), "|")); return replaceSubstring(startEndIndexPair, simpleQuery, replaceTerm); }  static String makeQueryPrefixAndFuzzy(@NonNull String simpleQuery); static String createLuceneQueryString(Collection<String> values, String operator,
                                                  Function<String, String> function); static String createLuceneQueryString(Collection<String> values, String operator);  }
@Test public void replaceTermWithFuzzyAndPrefixDisjunctionReplacesTermWithBracedDisjunction() { var simpleQuery = "java"; var expectedQuery = "(java | java~1 | java*)"; var startIndex = 0; var endIndex = 3; var startEndIndexPair = Pair.of(startIndex, endIndex); var actualQuery = HibernateSimpleQueryUtils.replaceTermWithFuzzyAndPrefixDisjunction(startEndIndexPair, simpleQuery); assertThat(actualQuery).isEqualTo(expectedQuery); }