Problem:

How to implement equals and hashcode using java.util.Objects? In the following example we show how to use these great, null-insensitive helper methods.

Solution:

Java 7 came with long time awaited utility class java.util.Objects. It contains static helper methods for working with objects. Here we show how to use equals and hash methods that are null-insensitive and ease implementation of equals and hashcode: