commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laurent Perez" <hak...@gmail.com>
Subject [lang] equalsBuilder unexplained wrong equality with java.lang.Longs ?
Date Sun, 16 Dec 2007 23:16:49 GMT
Hi !

I'm struggling with a problem I don't understand, my equalsBuilder's
isEquals seem to return false when dealing with Longs :

I have a bean class UiTheme, with a property private Long id.

The following equals builder will return false when this.id = 1 and
rhs.id =  1 :

	public boolean equals(Object object) {
		if (!(object instanceof UiTheme)) {
			return false;
		}
		UiTheme rhs = (UiTheme) object;
		return new EqualsBuilder().appendSuper(super.equals(object)).append(this.id,
rhs.id).isEquals();
	}

If I manually do the equality, as in this.id.equals(rhs.id), then it
is true (because, well... 1 = 1 !)
If I do an equality like this.id == rhs.id, then it is false (being a
Java newbie... maybe it should be false, not sure if doing == instead
of equals(obj) is correct with Longs)

So I assume (am I wrong ?) that equalsBuilder's isEquals uses "=="
instead of "equals(obj)"... but I really, really don't understand why.

Can anyone enlighten me ?

thanks !
-- 
<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