private static String normalizeHelper(String number,Map<Character,Character> normalizationReplacements,boolean removeNonMatches){
  StringBuilder normalizedNumber=new StringBuilder(number.length());
  for (int i=0; i < number.length(); i++) {
    char character=number.charAt(i);
    Character newDigit=normalizationReplacements.get(Character.toUpperCase(character));
    if (newDigit != null) {
      normalizedNumber.append(newDigit);
    }
 else     if (!removeNonMatches) {
      normalizedNumber.append(character);
    }
  }
  return normalizedNumber.toString();
}

private static String normalizeHelper ( String number , Map < Character , Character > normalizationReplacements , boolean removeNonMatches ) { StringBuilder normalizedNumber = new StringBuilder ( number . length ( ) ) ; for ( int i = 0 ; i < number . length ( ) ; i ++ ) { char character = number . charAt ( i ) ; Character newDigit = normalizationReplacements . get ( Character . toUpperCase ( character ) ) ; if ( newDigit != null ) { normalizedNumber . append ( newDigit ) ; } else if ( ! removeNonMatches ) { normalizedNumber . append ( character ) ; } } return normalizedNumber . toString ( ) ; }
normalizes a string of characters representing a phone number by replacing all characters found in the accompanying map with the values therein , and stripping all other characters if removenonmatches is true .
