int (final String expectedName, final List<String> words, int max) { if (expectedName == null) return max; String[] expectedWords = NameUtil.nameToWords(expectedName); int limit = Math.min(words.size(), expectedWords.length); for (int i = 0; i < limit; i++) { String word = words.get(words.size() - i - 1); String expectedWord = expectedWords[expectedWords.length - i - 1]; if ( word.equalsIgnoreCase(expectedWord) || StringUtil.endsWithIgnoreCase(word, expectedWord) || StringUtil.endsWithIgnoreCase(expectedWord, word)) { max = Math.max(max, i + 1); } else { break; } } return max; }