Locale.getISOCountries() Wrapper I have the following codes, i want to get a list of country CODE and NAME from Locale.getISOCountries() and set it into my custom made class, i managed to do it but i somehow feel that my codes is not clean enough, especially the getCountryList() part but i not sure how to minimize it, is there any suggestion? I don't mind to use lambda if possible.

private static List&lt;CountryPair&gt; getCountryList()
{
    String[] locales = Locale.getISOCountries();
    List&lt;String&gt; countryCodes = Arrays.asList(locales);
    List&lt;CountryPair&gt; pairList = new ArrayList&lt;&gt;();
    countryCodes.forEach(code -&gt; {
    CountryPair pair = new CountryPair();
    Locale locale = new Locale("", code);
    pair.setValue(locale.getCountry());
    pair.setDisplayName(locale.getDisplayCountry());
    pairList.add(pair);
    });
  return pairList;
}


Country pair class:

public class CountryPair {

    private String value;

    private String displayName;

    public String getValue() {
      return value;
    }

    public String getDisplayName() {
      return displayName;
    }

    public void setValue(String value) {
      this.value = value;
    }

    public void setDisplayName(String displayName) {
      this.displayName = displayName;
    }
}
My recommendation is: create a constructor for CountryPair, which takes the parameter values:

    public CountryPair(String value, String displayName) {
        this.value = value;
        this.displayName = displayName;
    }


Then, you can use an elegant map-chain:

    List&lt;CountryPair&gt; pairList = countryCodes.stream()
        .map(code -&gt; new Locale("", code))
        .map(locale -&gt; new CountryPair(locale.getCountry(), locale.getDisplayCountry()))
        .collect(Collectors.toList());


Alternatively, you could also use a constructor which uses the Locale object as a parameter.