List<GwtLocale> searchList = locale.getCompleteSearchList();
Map<GwtLocale, Integer> derivedIndex = new HashMap<GwtLocale, Integer>();
for (int i = 0; i < searchList.size(); ++i) {
derivedIndex.put(searchList.get(i), i);
}
GwtLocale defaultLocale = LocaleUtils.getLocaleFactory().getDefault();
GwtLocale best = defaultLocale;
int bestIdx = Integer.MAX_VALUE;
for (int i = 0; i < list.size(); ++i) {
GwtLocale matchLocale = list.get(i).getMatchLocale();
Integer wrappedIdx = derivedIndex.get(matchLocale);
if (wrappedIdx == null) {
// We had an @DefaultLocale for a locale not present in this
// permutation -- treat it as the default locale.
wrappedIdx = derivedIndex.get(defaultLocale);