> To resurrect this topic, I also have a pressing need for comparing two
> jaxb-generated objects by value. Other than the Map/hashCode issue
> presented by Mattias below and an increase in the size of the generated
> code, I cannot see any negatives to implementing this feature.
There are indeed technical difficulties.
One difficulty in correctly implementing the equals method is that we
need to be able to detect cycles.
Consider a generated interface like
interface Foo {
Foo getFoo();
void setFoo(Foo v);
}
And suppose you did:
Foo f = objectFactory.createFoo();
f.setFoo(f);
It's not good for "f.equals(f)" to throw a StackOverflowError.
This example is rather artificial, but the same problem happens if you
have ID/IDREFs.
Also, I looked around other object models, and I felt that most of them
don't implement value-based equality (but I could be wrong.)
But we appreciate your inputs.
regards,
--
Kohsuke KAWAGUCHI 408-276-7063 (x17063)
Sun Microsystems kohsuke.kawaguchi_at_sun.com