1 year ago
#372637
Farrukh Nabiyev
Lombok @EqualsAndHashcode
I am implementing Lombok @EqualsAndHashcode annotation. I need to control order of parameters included in hashCode() generation. For example Lombok generates this:
public int hashCode() {
final int prime = 59;
int result = 1;
result = prime * result + parOne; //First
result = prime * result + parTwo; //Second
return result;
}
But I need it to be like:
public int hashCode() {
final int prime = 59;
int result = 1;
result = prime * result + parTwo; //Second
result = prime * result + parOne; //First
return result;
}
Two methods above generate different hash codes. My question is: can I control order of parameters using Lombok?
I have already tried: @EqualsAndHashCode(doNotUseGetters = true, of = {"parTwo", "parOne"})
but it is not working.
java
equals
lombok
hashcode
0 Answers
Your Answer