class CountryCodeValidator {

    public static List<String> validate(List<String> countryCodes) {
        List<String> upperCaseCountries = Objects.requireNonNull(countryCodes).stream()
                .map(String::toUpperCase)
                .collect(toList());
        List<String> invalidCodes = upperCaseCountries.stream()
                .filter(s -> CountryCode.getByAlpha2Code(s) == null)
                .collect(toList());
        if (!invalidCodes.isEmpty()) {
            throw new IllegalArgumentException(
                    "Following elements (" + invalidCodes + ") are not valid ISO 3166-1 alpha-2 country codes");
        }
        List<String> uniqueCountries = upperCaseCountries.stream().distinct().collect(toList());
        if (uniqueCountries.size() < countryCodes.size()) {
            logger.warn("Duplicate items were removed from {}", countryCodes);
        }
        return uniqueCountries;
    }

    private  CountryCodeValidator();

}