Hi

I am looking to solve a compare and sync problem.

Lets say you have an Object that contains references to some more objects and each contains references to some more (word containment shouldnt be strictly used as there is no such thing as containment in java but lets move on)

Now I have 2 such references and I want to compare them. What are the alternatives to the "equals" method?

I find "equals" method error prone as I have to write equals for every reference (instance variable) and its child reference and so on, there is a chance for error.

To make myself clear, lets say we have a vector and the vector has a bunch of vectors and each vector has some objects. Now If a difference exists in any of these objects in each vector it is a difference in the object as a whole.
(This is an example, not the original scenario. In the original scenario, I have concrete instances of classes that have to be tested for equality via equals method which I find boring.)

Not only I have to do this but capture the difference and propagate the difference upwards to the user in a JSP.The user can update a particular component and I have to sync both instances.

Speaking of propagation, just look at the way exceptions are propagated to the upper level by default, wish we had such a technique to propagate a difference in comparison.


Thanks in advance
hemant