All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.youyinnn.common.utils.WsTioUuId Maven / Gradle / Ivy

There is a newer version: 1.0
Show newest version
package com.github.youyinnn.common.utils;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.RandomUtil;
import org.tio.core.intf.TioUuid;

/**
 * @author youyinnn
 */
public class WsTioUuId implements TioUuid {

    private Snowflake snowflake;

    public WsTioUuId() {
        snowflake = new Snowflake(RandomUtil.randomInt(1, 30), RandomUtil.randomInt(1, 30));
    }

    public WsTioUuId(long workerId, long dataCenterId) {
        snowflake = new Snowflake(workerId, dataCenterId);
    }

    @Override
    public String uuid() {
        return snowflake.nextId() + "_" + System.nanoTime();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy