commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guilherme Melo <guilherme...@gmail.com>
Subject [lang]
Date Sat, 21 Jul 2012 18:26:40 GMT
Hello All,

I have been running some Tests with
HashCodeBuilder.reflectionHashCode, and the outputted results are
inconsistent with those generated by "classical implementations", i.e.
eclipse's auto-generate and custom code following the descriptions in
"Effective Java" book. Below is a very simple example.

My test entity only has two string fields.

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((anotherFild == null) ? 0 : anotherFild.hashCode());
result = prime * result
+ ((someField == null) ? 0 : someField.hashCode());
return result;
}

test:
assertEquals(originalEntity.hashCode(),HashCodeBuilder.reflectionHashCode(1,
31, originalEntity));

Does the Builder use some different standard I am not aware of?

Cheers

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


Mime
View raw message