On 12/18/2012 12:13 AM,
Node a = new Gate();
Monitor b = new Monitor();
System.out.println(a.equals(b)); // --> prints 'true'
...
The underlying production code is a bit complex to include here. My
This is a red flag. The code should not be so complex that you can't
show us what is really going on. If it *is* too complex, then likely
the issue is the complexity itself.
However, I think Roedy zeroed in on the most likely cause. Your
abstract class, Node (or some superclass), implements equals()
*incorrectly* and is returning true when it should not. Probably Node()
should not implement equals() at all.
Show us the implementation of equals() for Node (and probably Gate too,
that version of equals() could also be borked in the example you gave)
and we'll point out the error.
It is complex because it is a large application. I can either post the several hundred lines of source or the the 6 which adequately illustrates the point. Node does not implement equals at all as you say