I have this code
public static boolean haveDuplicatesOfCurrency(List<Account> inputList){
Set<String> currencyCode = new HashSet<>();
for (Account account: inputList) {
boolean add = currencyCode.add(account.getCurrency());
if(!add){
return true;
}
}
return false;
}
This code check if I have duplicated values of certain fields in objects list.
I don't need to check other fields than currency.
Is there a better, more original way to check it?