Your implementation is fine as long as equal objects have the same hash code. That's the only requirement there is. How you calculate the hash code, that is, whether you use if-statements or not, is not important.
(Also, it would be nice if the hash code never changed during the object's life time, because it breaks pretty much any data structure that uses hash codes. Optimally the object should be immutable.)