private synchronized long nextId() {
        long timestamp = timeGen();
        if (timestamp < lastTimestamp) {
            throw new RuntimeException(String.format("Clock moved backwards.  Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
        }
        if (lastTimestamp == timestamp) {
            sequence = (sequence + 1) & SEQUENCE_MASK;
            if (sequence == 0) {
                timestamp = tilNextMillis(lastTimestamp);
            }
        } else {
            sequence = 0L;
        }

        lastTimestamp = timestamp;

        return ((timestamp - idepoch) << TIMESTAMP_LEFT_SHIFT)
                | (datacenterId << DATACENTER_ID_SHIFT)
                | (workerId << WORKER_ID_SHIFT) | sequence;
    }
@Test
    public void testNextId() throws Exception {
        UUIDUtils uuidUtils = UUIDUtils.getInstance();
        Class<?> uUIDUtilsClass = uuidUtils.getClass();
        Field field = uUIDUtilsClass.getDeclaredField("lastTimestamp");
        field.setAccessible(true);
        field.set(uuidUtils, System.currentTimeMillis());

        Method method = uUIDUtilsClass.getDeclaredMethod("nextId");
        method.setAccessible(true);
        method.invoke(UUIDUtils.getInstance());
    }