Overriding hashCode with a class with two generics fields
You are already relying on the left and right equals
methods so why not also rely on their hashcodes
?
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + (left ==null? 0 : left.hashCode());
result = prime * result + (right ==null? 0 : right.hashCode());
return result;
}
Don’t reinvent the wheel.
Just use return Objects.hash(left, right);