// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SnowflakeConfig.java

package com.example.ghjgpython.conf;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.net.NetUtil;
import cn.hutool.core.util.IdUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SnowflakeConfig
{

    public SnowflakeConfig()
    {
        workerId = 0L;
        datacenterId = 1L;
        snowflake = IdUtil.createSnowflake(workerId, datacenterId);
    }

    public void init()
    {
        workerId = NetUtil.ipv4ToLong(NetUtil.getLocalhostStr());
    }

    public synchronized String snowflakeId()
    {
        return String.valueOf(snowflake.nextId());
    }

    public synchronized Long snowflakeIdLong()
    {
        return Long.valueOf(snowflake.nextId());
    }

    public synchronized String snowflakeId(long workerId, long datacenterId)
    {
        Snowflake snowflake = IdUtil.createSnowflake(workerId, datacenterId);
        return String.valueOf(snowflake.nextId());
    }

    private static final Logger log = LoggerFactory.getLogger(SnowflakeConfig.class);
    private long workerId;
    private long datacenterId;
    private Snowflake snowflake;

}
