@Test public void getIndexAfterFirstAppearanceOfReturnsMinusOneWhenStartIndexGreaterThanInputLength() { var input = "test"; var character = '"'; var expectedIndex = -1; var startIndex = input.length(); var actualIndex = HibernateSimpleQueryUtils.getIndexAfterFirstAppearanceOf(startIndex, character, input); assertThat(actualIndex).isEqualTo(expectedIndex); }
static int getIndexAfterFirstAppearanceOf(int startIndex, char character, String searchedString) { var queryCharCount = searchedString.length(); if(startIndex >= queryCharCount) { return -1; } var indexAfterFirstAppearance = searchedString.substring(startIndex).indexOf(character) + startIndex + 1; if(indexAfterFirstAppearance > 0 && indexAfterFirstAppearance < queryCharCount) { return indexAfterFirstAppearance; } return -1; }
HibernateSimpleQueryUtils { static int getIndexAfterFirstAppearanceOf(int startIndex, char character, String searchedString) { var queryCharCount = searchedString.length(); if(startIndex >= queryCharCount) { return -1; } var indexAfterFirstAppearance = searchedString.substring(startIndex).indexOf(character) + startIndex + 1; if(indexAfterFirstAppearance > 0 && indexAfterFirstAppearance < queryCharCount) { return indexAfterFirstAppearance; } return -1; } }
HibernateSimpleQueryUtils { static int getIndexAfterFirstAppearanceOf(int startIndex, char character, String searchedString) { var queryCharCount = searchedString.length(); if(startIndex >= queryCharCount) { return -1; } var indexAfterFirstAppearance = searchedString.substring(startIndex).indexOf(character) + startIndex + 1; if(indexAfterFirstAppearance > 0 && indexAfterFirstAppearance < queryCharCount) { return indexAfterFirstAppearance; } return -1; }  }
HibernateSimpleQueryUtils { static int getIndexAfterFirstAppearanceOf(int startIndex, char character, String searchedString) { var queryCharCount = searchedString.length(); if(startIndex >= queryCharCount) { return -1; } var indexAfterFirstAppearance = searchedString.substring(startIndex).indexOf(character) + startIndex + 1; if(indexAfterFirstAppearance > 0 && indexAfterFirstAppearance < queryCharCount) { return indexAfterFirstAppearance; } 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 getIndexAfterFirstAppearanceOf(int startIndex, char character, String searchedString) { var queryCharCount = searchedString.length(); if(startIndex >= queryCharCount) { return -1; } var indexAfterFirstAppearance = searchedString.substring(startIndex).indexOf(character) + startIndex + 1; if(indexAfterFirstAppearance > 0 && indexAfterFirstAppearance < queryCharCount) { return indexAfterFirstAppearance; } 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);  }