> if (mateId != (mateId << mateIdShift) >>> mateIdShift))

What I'm testing for here is that there are no significant bits lost.

Let's say I have a field with 3 bits: `0000 0XXX`.  The expression `~(-1 << numBitsInDataStructure)` gives a mask like `0000 0111` which when `&`'ed with the original value will clear all the significant bits.  If the cleared value `!=` the original value, then the passed argument is invalid and some bits would be lost (this is like an overflow flag).