class SerialNumber implements Comparable<SerialNumber> {

    public boolean isBefore(SerialNumber that) {
        long i1 = Integer.toUnsignedLong(this.value);
        long i2 = Integer.toUnsignedLong(that.value);
        return (this.value != that.value && (
            i1 < i2 && (i2 - i1) < HALF_SERIAL_NUMBER_RANGE
                || i1 > i2 && (i1 - i2) > HALF_SERIAL_NUMBER_RANGE
        ));
    }

}