It might happen that you need to deduplicate a list of items… coming from legacy code. The class - let’s call it LegacyObject has already implementations for equals() and hashCode(). It’s not possible to change the implementation, for fear of breaking the running code. And unfortunately, the Java API doesn’t offer a distinctBy() feature. In that case, a cheap trick is to create a wrapper class around LegacyObject, with the desired implementation: public class L