You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Guilherme Melo <gu...@gmail.com> on 2012/07/21 20:26:40 UTC
[lang]
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