users@jaxb.java.net

equals() and hashCode()

From: <Andrew.Ferguson_at_arm.com>
Date: Mon, 17 Nov 2003 13:09:41 +0000

hi,

 I've been reading this thread


https://jaxb.dev.java.net/servlets/SearchList?list=users&searchText=equals&defaultField=subject&Search=Search

and was wondering what the current thinking is on defining equals and
hashCode methods on JAXB generated classes?

One point I didn't see mentioned in the thread above was that its arguable
that object graphs containing cycles aren't going to occur very naturally
with XML* (?) - ie by going with the
straightforward implementation of equals and hashCode you'd probably make
90% of users happy (and those who get StackOverflowErrors would likely be
aware that they were dealing with cyclic
data structures and be able to diagnose this quickly).

Has anyone tried the workarounds suggested? Performance isn't an issue so
I'm happy to use Jakarta's reflective EqualsBuilder but wasn't sure that
all fields in JAXB generated classes should be processed by this. If all
fields should not be included as a definition of equality, is there some
automatic way to determine which should?

any help appreciated,
thanks,
Andrew
*eg. if I understand correctly then unmarshalling couldn't produce an
object graph with cycles? If a user creates an object graph with cycles and
tries to marshall it then its reasonable for the marshaller to go into a
loop - what else might the user mean?



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net