I have a simple enum that I am iterating through to check if it contains a specific value. Here is my code -
private static boolean checkCountryCode(CountryCode countryCode) {
return Arrays.asList(CountryCodeList.values()).contains(countryCode.name());
}
This always returns false although the country code I am passing in the request is present in the list. In this case, I can't override equals since its a enum.
The countryCode in the method argument has the countryCode I am passing in the request. In my case, it is UA (Ukraine). The CountryCodeList is a list pre-populated with all the country codes in which our application runs. Some of them are on this page - http://countrycode.org/
Also, please note both CountryCode, and CountryCodeList are enums.