'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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
