List<BytesRef> expandTermsIfRewrite(BytesRef[] terms,Map<BytesRef,Spans> strictPhrasesTermToSpans){
  if (willRewrite()) {
    Set<BytesRef> allTermSet=new LinkedHashSet<>(terms.length + strictPhrasesTermToSpans.size());
    Collections.addAll(allTermSet,terms);
    if (allTermSet.addAll(strictPhrasesTermToSpans.keySet())) {
      List<BytesRef> sourceTerms=Arrays.asList(allTermSet.toArray(new BytesRef[allTermSet.size()]));
      sourceTerms.sort(Comparator.naturalOrder());
      return sourceTerms;
    }
  }
  return Arrays.asList(terms);
}

List < BytesRef > expandTermsIfRewrite ( BytesRef [ ] terms , Map < BytesRef , Spans > strictPhrasesTermToSpans ) { if ( willRewrite ( ) ) { Set < BytesRef > allTermSet = new LinkedHashSet < > ( terms . length + strictPhrasesTermToSpans . size ( ) ) ; Collections . addAll ( allTermSet , terms ) ; if ( allTermSet . addAll ( strictPhrasesTermToSpans . keySet ( ) ) ) { List < BytesRef > sourceTerms = Arrays . asList ( allTermSet . toArray ( new BytesRef [ allTermSet . size ( ) ] ) ) ; sourceTerms . sort ( Comparator . naturalOrder ( ) ) ; return sourceTerms ; } } return Arrays . asList ( terms ) ; }
returns terms as a list , but expanded to any terms in strictphrases ' keyset if present . that can only happen if willrewrite ( ) is true .
