record MyRecord(int a, int b, int hash) {
MyRecord(int a, int b) {
this(a, b, Objects.hash(a, b));
}
@Deprecated
MyRecord {
}
@Override
public int hashCode() {
return hash;
}
}
That said, I consider this an odd usage of records and would never do it myself. If I was convinced that I needed to precompute hash codes I would go with an old fashioned hand written value class.