code: protected static <E extends Enum<E> & ByteEnum> int toIntFlag (E value)
      {
          byte code = value.toByte(); // allow this to throw NPE
          if (code < 0 || code > 31) {
              throw new IllegalArgumentException(
                  "ByteEnum code is outside the range that can be turned into an int " +
                  "[value=" + value + ", code=" + code + "]");
          }
          return (1 << code);
      }
docs: A helper function for setToInt() and intToSet() that validates that the specified
  ByteEnum value is not null and has a code between 0 and 31, inclusive.