@SuppressWarnings("fallthrough") public static Automaton toAutomaton(Term wildcardquery){
  List<Automaton> automata=new ArrayList<>();
  String wildcardText=wildcardquery.text();
  for (int i=0; i < wildcardText.length(); ) {
    final int c=wildcardText.codePointAt(i);
    int length=Character.charCount(c);
switch (c) {
case WILDCARD_STRING:
      automata.add(Automata.makeAnyString());
    break;
case WILDCARD_CHAR:
  automata.add(Automata.makeAnyChar());
break;
case WILDCARD_ESCAPE:
if (i + length < wildcardText.length()) {
final int nextChar=wildcardText.codePointAt(i + length);
length+=Character.charCount(nextChar);
automata.add(Automata.makeChar(nextChar));
break;
}
default :
automata.add(Automata.makeChar(c));
}
i+=length;
}
return Operations.concatenate(automata);
}

@ SuppressWarnings ( "fallthrough" ) public static Automaton toAutomaton ( Term wildcardquery ) { List < Automaton > automata = new ArrayList < > ( ) ; String wildcardText = wildcardquery . text ( ) ; for ( int i = 0 ; i < wildcardText . length ( ) ; ) { final int c = wildcardText . codePointAt ( i ) ; int length = Character . charCount ( c ) ; switch ( c ) { case WILDCARD_STRING : automata . add ( Automata . makeAnyString ( ) ) ; break ; case WILDCARD_CHAR : automata . add ( Automata . makeAnyChar ( ) ) ; break ; case WILDCARD_ESCAPE : if ( i + length < wildcardText . length ( ) ) { final int nextChar = wildcardText . codePointAt ( i + length ) ; length += Character . charCount ( nextChar ) ; automata . add ( Automata . makeChar ( nextChar ) ) ; break ; } default : automata . add ( Automata . makeChar ( c ) ) ; } i += length ; } return Operations . concatenate ( automata ) ; }
convert lucene wildcard syntax into an automaton .
