commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laurent Perez" <hak...@gmail.com>
Subject Re: [lang] equalsBuilder unexplained wrong equality with java.lang.Longs ?
Date Mon, 17 Dec 2007 12:37:30 GMT
(sorry for the double list post if two mails went in, I received a
mailer daemon error on two posts attemps)

Thanks Gary for your explanation, I also had a look at Long javadoc
and seeing its overriden equals(), I understand my false boolean when
doing "==".

However, as Jörg said, I don't understand why EqualsBuilder isEquals
seem to use object identity "==" and not identitity.

I thought it may be related to the appendSuper(super.equals(object)),
but my bean does not extend some weird class, however, it implements
Serializable, with an eclipse-generated serialVersionUID of
4428981846813391173L.

Would it relate to my hashcode() instead ? Mine uses the Long id
property too, and is :
public int hashCode() {
		return new HashCodeBuilder(1054718011, -1215537567).appendSuper(
				super.hashCode()).append(this.id).toHashCode();
	}

laurent

2007/12/17, Jörg Schaible <Joerg.Schaible@elsag-solutions.com>:
> Gary Gregory wrote:
> > Hello Laurent:
> >
> > This behavior is 'normal'. The concepts of object equality
> > (the equals() method) and object identity (==) are different.
>
> Well, this was not Laurent's question. He was wondering, why the EqualsBuilder seems
to use in his example the Long objects' identity instead of their equals method.
>
> [snip]
>
> - Jörg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


-- 
<a href="http://in-pocket.blogspot.com">http://in-pocket.blogspot.com
- Mobile world, technology and more</a>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message