public static Country findByIso3166alpha3Code(String code) { for (Country country : Bennu.getInstance().getCountriesSet()) { if (country.getIso3166alpha3Code().equalsIgnoreCase(code)) { return country; } } return null; }
public static Country findByAcronym(String acronym) { for (Country country : Bennu.getInstance().getCountriesSet()) { if (country.getAcronym().equalsIgnoreCase(acronym)) { return country; } } return null; }
public static Country findByName(String name) { for (Country country : Bennu.getInstance().getCountriesSet()) { for (Locale locale : country.getName().getLocales()) { if (country.getName().getContent(locale).equalsIgnoreCase(name)) { return country; } } } return null; }
@Override public int compare(final Country country1, Country country2) { final String name1 = country1.getName().getContent(); final String name2 = country2.getName().getContent(); final int c = Collator.getInstance().compare(name1, name2); if (c == 0) { final String acronym1 = country1.getAcronym(); final String acronym2 = country2.getAcronym(); if (acronym1 == null || acronym2 == null) { return country2.hashCode() - country1.hashCode(); } final int a = Collator.getInstance().compare(acronym1, acronym2); return a == 0 ? country2.hashCode() - country1.hashCode() : a; } return c; }