The answer depends a bit on the answer to a philosophical question: what does equality mean?
One general answer that is used a lot is that equality means all the member variables pass the equals()
test. For simple variables, you just test .equals() for each one.
For contained objects, you do .equals() on each object contained.
This still leaves philosophical questions. Suppose your object contains a Set. This interface can be backed/implemented by any of a number of concrete sets. TreeSet, HashSet, ImmutableSet, etc. Plus, the TreeSet can have different Comparators. So if one object contains say a TreeSet in ascending order, and another has a TreeSet in descending order, but both have elements that pass the .equals() test inside a for() loop, are they equal?