LocaleComparator implements Comparator<Locale> { public int compare(Locale l1, Locale l2) { if (selectedCompareType == CompareType.COUNTRY) { return l1.getDisplayCountry().compareTo(l2.getDisplayCountry()); } else { return l1.getDisplayName().compareTo(l2.getDisplayName()); } } LocaleComparator(CompareType compareType); int compare(Locale l1, Locale l2);  }
@Test public void testCompareCountry() { Locale l1 = Locale.CANADA; Locale l2 = Locale.JAPAN; assertTrue(new LocaleComparator(CompareType.COUNTRY).compare(l1, l2) != 0); }
@Test public void testCompareLanguage() { Locale l1 = Locale.FRANCE; Locale l2 = Locale.ENGLISH; assertTrue(new LocaleComparator(CompareType.LANGUAGE).compare(l1, l2) != 0); }