I am using a function call is filter on a stream like below -
list.stream()
.filter(a -> !StringUtils.isEmpty(a.getProp1()))
.filter(a -> !a.getProp1().matches(“(.*)xyz"))
.filter(a -> {try {
return isValid(a.getProp1());
} catch (javax.naming.NamingException e) {
logger.error("Error");
}
})
I referred to the question But I don't want to throw an exception in the catch block. I just want to log it.
I want to retain the records which return true on invoking isValid(a) and then be able to collect it in a HashSet like below --
// .collect(Collectors.toCollection(HashSet::new));
It must be obvious from code but I am new to java 8 and still learning concepts. Please pardon any naive code. Thanks for any help.