I have an address object that I want to create an equals method for. I could have made this quite simple by doing something like the following (shortened a bit):
You can use a helper method like
public static boolean isEqual(Object o1, Object o2) { return o1 == o2 || (o1 != null && o1.equals(o2)); }