test_class.file: backend/project-board/src/test/java/de/adesso/projectboard/base/search/HibernateSimpleQueryUtilsTest.java
test_class.identifier: HibernateSimpleQueryUtilsTest
test_case.body: @Test
      public void getReplaceableTermsOfQueryReturnsExpectedPairOfNotQueryWithMultipleTerms() {
          // given
          var simpleQuery = "-(test spring)";
          var expectedPairs = List.of(
                  Pair.of(2, 5),
                  Pair.of(7, 12)
          );
  
          // when
          var actualPairs = HibernateSimpleQueryUtils.getReplaceableTermsOfQuery(simpleQuery);
  
          // then
          assertThat(actualPairs).containsExactlyInAnyOrderElementsOf(expectedPairs);
      }
test_case.class_method_signature: HibernateSimpleQueryUtilsTest.getReplaceableTermsOfQueryReturnsExpectedPairOfNotQueryWithMultipleTerms()
test_case.full_signature: @Test public void getReplaceableTermsOfQueryReturnsExpectedPairOfNotQueryWithMultipleTerms()
test_case.identifier: getReplaceableTermsOfQueryReturnsExpectedPairOfNotQueryWithMultipleTerms
test_case.invocations: of of of getReplaceableTermsOfQuery containsExactlyInAnyOrderElementsOf assertThat
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void getReplaceableTermsOfQueryReturnsExpectedPairOfNotQueryWithMultipleTerms()
focal_class.declarator: TERM_DELIMITER = Set.of('(', ')', '|', ' ', '&', '-')
focal_class.modifier: private static final
focal_class.original_string: private static final Set<Character> TERM_DELIMITER = Set.of('(', ')', '|', ' ', '&', '-');
focal_class.type: Set<Character>
focal_class.var_name: TERM_DELIMITER
focal_class.declarator: SPECIAL_CHARACTERS = Set.of('~', '*')
focal_class.modifier: private static final
focal_class.original_string: private static final Set<Character> SPECIAL_CHARACTERS = Set.of('~', '*');
focal_class.type: Set<Character>
focal_class.var_name: SPECIAL_CHARACTERS
focal_class.file: backend/project-board/src/main/java/de/adesso/projectboard/base/search/HibernateSimpleQueryUtils.java
focal_class.identifier: HibernateSimpleQueryUtils
focal_class.class_method_signature: HibernateSimpleQueryUtils.makeQueryPrefixAndFuzzy(@NonNull String simpleQuery)
focal_class.full_signature: public static String makeQueryPrefixAndFuzzy(@NonNull String simpleQuery)
focal_class.identifier: makeQueryPrefixAndFuzzy
focal_class.modifiers: public static
focal_class.parameters: (@NonNull String simpleQuery)
focal_class.return: String
focal_class.signature: String makeQueryPrefixAndFuzzy(@NonNull String simpleQuery)
focal_class.class_method_signature: HibernateSimpleQueryUtils.replaceTermWithFuzzyAndPrefixDisjunction(Pair<Integer, Integer> startEndIndexPair, String simpleQuery)
focal_class.full_signature: static String replaceTermWithFuzzyAndPrefixDisjunction(Pair<Integer, Integer> startEndIndexPair, String simpleQuery)
focal_class.identifier: replaceTermWithFuzzyAndPrefixDisjunction
focal_class.modifiers: static
focal_class.parameters: (Pair<Integer, Integer> startEndIndexPair, String simpleQuery)
focal_class.return: String
focal_class.signature: String replaceTermWithFuzzyAndPrefixDisjunction(Pair<Integer, Integer> startEndIndexPair, String simpleQuery)
focal_class.class_method_signature: HibernateSimpleQueryUtils.replaceSubstring(Pair<Integer, Integer> startEndIndexPair, String stringToReplaceIn, String replacement)
focal_class.full_signature: static String replaceSubstring(Pair<Integer, Integer> startEndIndexPair, String stringToReplaceIn, String replacement)
focal_class.identifier: replaceSubstring
focal_class.modifiers: static
focal_class.parameters: (Pair<Integer, Integer> startEndIndexPair, String stringToReplaceIn, String replacement)
focal_class.return: String
focal_class.signature: String replaceSubstring(Pair<Integer, Integer> startEndIndexPair, String stringToReplaceIn, String replacement)
focal_class.class_method_signature: HibernateSimpleQueryUtils.getIndexAfterFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString)
focal_class.full_signature: static int getIndexAfterFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString)
focal_class.identifier: getIndexAfterFirstAppearanceOfAny
focal_class.modifiers: static
focal_class.parameters: (int startIndex, Set<Character> characters, String searchedString)
focal_class.return: int
focal_class.signature: int getIndexAfterFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString)
focal_class.class_method_signature: HibernateSimpleQueryUtils.getIndexAfterFirstAppearanceOf(int startIndex, char character, String searchedString)
focal_class.full_signature: static int getIndexAfterFirstAppearanceOf(int startIndex, char character, String searchedString)
focal_class.identifier: getIndexAfterFirstAppearanceOf
focal_class.modifiers: static
focal_class.parameters: (int startIndex, char character, String searchedString)
focal_class.return: int
focal_class.signature: int getIndexAfterFirstAppearanceOf(int startIndex, char character, String searchedString)
focal_class.class_method_signature: HibernateSimpleQueryUtils.getIndexOfFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString)
focal_class.full_signature: static int getIndexOfFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString)
focal_class.identifier: getIndexOfFirstAppearanceOfAny
focal_class.modifiers: static
focal_class.parameters: (int startIndex, Set<Character> characters, String searchedString)
focal_class.return: int
focal_class.signature: int getIndexOfFirstAppearanceOfAny(int startIndex, Set<Character> characters, String searchedString)
focal_class.class_method_signature: HibernateSimpleQueryUtils.getIndexAfterPhraseTerm(int startIndex, String simpleQuery)
focal_class.full_signature: static int getIndexAfterPhraseTerm(int startIndex, String simpleQuery)
focal_class.identifier: getIndexAfterPhraseTerm
focal_class.modifiers: static
focal_class.parameters: (int startIndex, String simpleQuery)
focal_class.return: int
focal_class.signature: int getIndexAfterPhraseTerm(int startIndex, String simpleQuery)
focal_class.class_method_signature: HibernateSimpleQueryUtils.getReplaceableTermsOfQuery(String simpleQuery)
focal_class.full_signature: static List<Pair<Integer, Integer>> getReplaceableTermsOfQuery(String simpleQuery)
focal_class.identifier: getReplaceableTermsOfQuery
focal_class.modifiers: static
focal_class.parameters: (String simpleQuery)
focal_class.return: List<Pair<Integer, Integer>>
focal_class.signature: List<Pair<Integer, Integer>> getReplaceableTermsOfQuery(String simpleQuery)
focal_class.class_method_signature: HibernateSimpleQueryUtils.createLuceneQueryString(Collection<String> values, String operator,
                                                    Function<String, String> function)
focal_class.full_signature: public static String createLuceneQueryString(Collection<String> values, String operator,
                                                    Function<String, String> function)
focal_class.identifier: createLuceneQueryString
focal_class.modifiers: public static
focal_class.parameters: (Collection<String> values, String operator,
                                                    Function<String, String> function)
focal_class.return: String
focal_class.signature: String createLuceneQueryString(Collection<String> values, String operator,
                                                    Function<String, String> function)
focal_class.class_method_signature: HibernateSimpleQueryUtils.createLuceneQueryString(Collection<String> values, String operator)
focal_class.full_signature: public static String createLuceneQueryString(Collection<String> values, String operator)
focal_class.identifier: createLuceneQueryString
focal_class.modifiers: public static
focal_class.parameters: (Collection<String> values, String operator)
focal_class.return: String
focal_class.signature: String createLuceneQueryString(Collection<String> values, String operator)
focal_method.body: static List<Pair<Integer, Integer>> getReplaceableTermsOfQuery(String simpleQuery) {
          var termIndexPairs = new ArrayList<Pair<Integer, Integer>>();
          var queryCharCount = simpleQuery.length();
  
          var index = 0;
          while(index >= 0 && index < queryCharCount) {
              var currentChar = simpleQuery.charAt(index);
  
              // skip term delimiters
              if(TERM_DELIMITER.contains(currentChar)) {
                  index++;
                  continue;
              }
  
              // ignore phrase terms and near operators
              if(currentChar == '"') {
                  index = getIndexAfterPhraseTerm(index, simpleQuery);
                  continue;
              }
  
              var nextSpecialCharIndex = getIndexOfFirstAppearanceOfAny(index, SPECIAL_CHARACTERS, simpleQuery);
              var nextTermDelimiterIndex = getIndexOfFirstAppearanceOfAny(index, TERM_DELIMITER, simpleQuery);
  
              // no term delimiter found after the current term
              if(nextTermDelimiterIndex < 0) {
                  nextTermDelimiterIndex = queryCharCount;
              }
              var termEndIndex = nextTermDelimiterIndex - 1;
  
              // when a term delimiter is present and the term is not a fuzzy or prefix term add
              // the pair -> ignore fuzzy and prefix terms
              var isSimpleTerm = nextSpecialCharIndex < 0 || nextTermDelimiterIndex < nextSpecialCharIndex;
              if(isSimpleTerm) {
                  termIndexPairs.add(Pair.of(index, termEndIndex));
  
                  index = nextTermDelimiterIndex + 1;
              } else {
                  // skip this term
                  index = getIndexAfterFirstAppearanceOfAny(nextSpecialCharIndex, TERM_DELIMITER, simpleQuery);
              }
          }
  
          return termIndexPairs;
      }
focal_method.class_method_signature: HibernateSimpleQueryUtils.getReplaceableTermsOfQuery(String simpleQuery)
focal_method.full_signature: static List<Pair<Integer, Integer>> getReplaceableTermsOfQuery(String simpleQuery)
focal_method.identifier: getReplaceableTermsOfQuery
focal_method.invocations: length charAt contains getIndexAfterPhraseTerm getIndexOfFirstAppearanceOfAny getIndexOfFirstAppearanceOfAny add of getIndexAfterFirstAppearanceOfAny
focal_method.modifiers: static
focal_method.parameters: (String simpleQuery)
focal_method.return: List<Pair<Integer, Integer>>
focal_method.signature: List<Pair<Integer, Integer>> getReplaceableTermsOfQuery(String simpleQuery)