private boolean areEqual ( final char x , final char y ) { if ( x == y ) { return true ; } if ( dictionaryMetadata . getEquivalentChars ( ) != null ) { List < Character > chars = dictionaryMetadata . getEquivalentChars ( ) . get ( x ) ; if ( chars != null && chars . contains ( y ) ) { return true ; } } if ( dictionaryMetadata . isIgnoringDiacritics ( ) ) { String xn = Normalizer . normalize ( Character . toString ( x ) , Form . NFD ) ; String yn = Normalizer . normalize ( Character . toString ( y ) , Form . NFD ) ; if ( xn . charAt ( 0 ) == yn . charAt ( 0 ) ) { // avoid case conversion, if possible return true ; } if ( dictionaryMetadata . isConvertingCase ( ) ) { //again case conversion only when needed -- we // do not need String.lowercase because we only check // single characters, so a cheaper method is enough if ( Character . isLetter ( xn . charAt ( 0 ) ) ) { boolean testNeeded = Character . isLowerCase ( xn . charAt ( 0 ) ) != Character . isLowerCase ( yn . charAt ( 0 ) ) ; if ( testNeeded ) { return Character . toLowerCase ( xn . charAt ( 0 ) ) == Character . toLowerCase ( yn . charAt ( 0 ) ) ; } } } return xn . charAt ( 0 ) == yn . charAt ( 0 ) ; } return false ; }
by Jaume Ortola