@Test public void getIndexOfFirstAppearanceOfAnyReturnsMinusOneWhenStartIndexGreaterThanInputLength() { var input = "abcd"; var characters = Set.of('b'); var startIndex = 3; var expectedIndex = -1; var actualIndex = HibernateSimpleQueryUtils.getIndexOfFirstAppearanceOfAny(startIndex, characters, input); assertThat(actualIndex).isEqualTo(expectedIndex); }
static int getIndexOfFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString) { var queryCharCount = searchedString.length(); if(startIndex >= queryCharCount) { return -1; } for(var currentIndex = startIndex; currentIndex < queryCharCount; currentIndex++) { if(characters.contains(searchedString.charAt(currentIndex))) { return currentIndex; } } return -1; }
HibernateSimpleQueryUtils { static int getIndexOfFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString) { var queryCharCount = searchedString.length(); if(startIndex >= queryCharCount) { return -1; } for(var currentIndex = startIndex; currentIndex < queryCharCount; currentIndex++) { if(characters.contains(searchedString.charAt(currentIndex))) { return currentIndex; } } return -1; } }
HibernateSimpleQueryUtils { static int getIndexOfFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString) { var queryCharCount = searchedString.length(); if(startIndex >= queryCharCount) { return -1; } for(var currentIndex = startIndex; currentIndex < queryCharCount; currentIndex++) { if(characters.contains(searchedString.charAt(currentIndex))) { return currentIndex; } } return -1; }  }
HibernateSimpleQueryUtils { static int getIndexOfFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString) { var queryCharCount = searchedString.length(); if(startIndex >= queryCharCount) { return -1; } for(var currentIndex = startIndex; currentIndex < queryCharCount; currentIndex++) { if(characters.contains(searchedString.charAt(currentIndex))) { return currentIndex; } } return -1; }  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); }
HibernateSimpleQueryUtils { static int getIndexOfFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString) { var queryCharCount = searchedString.length(); if(startIndex >= queryCharCount) { return -1; } for(var currentIndex = startIndex; currentIndex < queryCharCount; currentIndex++) { if(characters.contains(searchedString.charAt(currentIndex))) { return currentIndex; } } return -1; }  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);  }