how to do X in Java when working on Java projects. I guess this is common among people who are able to code in a lot of languages. 😛
const isUdeSCategory = (category) => category.displayName === "UdeS";
But, as always, in Java, you have to know the right class to do the same... In this case, after discovering the
Predicate class, I was able to quicly adapt my code as I wanted:
final Predicate<OutlookCategory> isUdeSCategory = category -> category?.displayName == "UdeS"; // To keep things simple, I used the equal comparison, but in reality, the function looks like as // final Predicate<OutlookCategory> predicate = category -> Objects.equals(category.displayName, "UdeS"); // to be null-safe.
If you want to know more about the
Predicate interface, JournalDev has a quick article on it named Java Predicate.
I'm pretty sure there are other interfaces for other types of arrow functions in Java, but I guess I'll learn them when I need to! 😉