import com.google.common.base.Objects; public class Employee { private String name; private int id; // Constructor and Getters/Setters @Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof Employee)) { return false; } Employee employee = (Employee) o; return Objects.equal(id, employee.id) && Objects.equal(name, employee.name); } // hashcode implementation }In the above code example, the equal() method from com.google.common.base.Objects is used to compare the fields of two Employee objects ensuring that if the two objects are null, it would return true even if both are null. Package Library: The com.google.common.base package is a part of Google Guava library.