@Test public void getIndexAfterPhraseTermReturnsMinusOneWhenQuotationNearOperatorIs() { var simpleQuery = "\"java\""; var startIndex = 0; var expectedIndex = -1; var actualIndex = HibernateSimpleQueryUtils.getIndexAfterPhraseTerm(startIndex, simpleQuery); assertThat(actualIndex).isEqualTo(expectedIndex); }
static int getIndexAfterPhraseTerm(int startIndex, String simpleQuery) { var queryCharCount = simpleQuery.length(); if(startIndex >= queryCharCount) { return -1; } var endIndex = getIndexAfterFirstAppearanceOf(startIndex + 1, '"', simpleQuery); if(endIndex > 0 && endIndex < queryCharCount && simpleQuery.charAt(endIndex) == '~') { endIndex = getIndexAfterFirstAppearanceOfAny(endIndex, TERM_DELIMITER, simpleQuery); } return endIndex; }
HibernateSimpleQueryUtils { static int getIndexAfterPhraseTerm(int startIndex, String simpleQuery) { var queryCharCount = simpleQuery.length(); if(startIndex >= queryCharCount) { return -1; } var endIndex = getIndexAfterFirstAppearanceOf(startIndex + 1, '"', simpleQuery); if(endIndex > 0 && endIndex < queryCharCount && simpleQuery.charAt(endIndex) == '~') { endIndex = getIndexAfterFirstAppearanceOfAny(endIndex, TERM_DELIMITER, simpleQuery); } return endIndex; } }
HibernateSimpleQueryUtils { static int getIndexAfterPhraseTerm(int startIndex, String simpleQuery) { var queryCharCount = simpleQuery.length(); if(startIndex >= queryCharCount) { return -1; } var endIndex = getIndexAfterFirstAppearanceOf(startIndex + 1, '"', simpleQuery); if(endIndex > 0 && endIndex < queryCharCount && simpleQuery.charAt(endIndex) == '~') { endIndex = getIndexAfterFirstAppearanceOfAny(endIndex, TERM_DELIMITER, simpleQuery); } return endIndex; }  }
HibernateSimpleQueryUtils { static int getIndexAfterPhraseTerm(int startIndex, String simpleQuery) { var queryCharCount = simpleQuery.length(); if(startIndex >= queryCharCount) { return -1; } var endIndex = getIndexAfterFirstAppearanceOf(startIndex + 1, '"', simpleQuery); if(endIndex > 0 && endIndex < queryCharCount && simpleQuery.charAt(endIndex) == '~') { endIndex = getIndexAfterFirstAppearanceOfAny(endIndex, TERM_DELIMITER, simpleQuery); } return endIndex; }  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 getIndexAfterPhraseTerm(int startIndex, String simpleQuery) { var queryCharCount = simpleQuery.length(); if(startIndex >= queryCharCount) { return -1; } var endIndex = getIndexAfterFirstAppearanceOf(startIndex + 1, '"', simpleQuery); if(endIndex > 0 && endIndex < queryCharCount && simpleQuery.charAt(endIndex) == '~') { endIndex = getIndexAfterFirstAppearanceOfAny(endIndex, TERM_DELIMITER, simpleQuery); } return endIndex; }  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);  }