When using lombok @Data (which adds EqualsAndHashCode)
It adds canEqual method
protected boolean canEqual(Object other) { return other instanceof Exercise; }
which is only called once:
if (!other.canEqual((Object)this)) return false;
I search and found discussions about access level
If you implement equals and hashCode in a non-final class the safest thing we can do is add the can equal the way we do. Since we don't add any field the costs, especially if the method is protected, are slim.
But why do we need this generated method ? can't it be inline?