CommonUtils { public static int getSeverTokenById(long id){ long tokenBitLength = IdGenerator.getDatacenterIdBits() + IdGenerator.getServerIdBits(); long tokenBitMax = ~(-1L << tokenBitLength); return (int)((id >> IdGenerator.getSequenceBits()) & tokenBitMax); }  static int getSeverTokenById(long id);  }
@Test void getSeverTokenById() { IdGenerator idGenerator = idGeneratorFactory.getRoleIdGenerator(); Long generate1 = idGenerator.generate(); Long generate2 = idGenerator.generate(); int severTokenById1 = CommonUtils.getSeverTokenById(generate1); int severTokenById2 = CommonUtils.getSeverTokenById(generate2); logger.debug("{}",Integer.toBinaryString(severTokenById1)); Assertions.assertEquals(severTokenById1,severTokenById2); }