package com.ycwl.basic.model.snowFlake;

import io.swagger.annotations.ApiModelProperty;

public class UniqueIdMetaData {
    /**
     * 取当前系统启动时间为参考起始时间，
     * 取1995-04-01为参考日
     */
//    public static final long START_TIME = LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli();
    public static final long START_TIME = 796665600000L;

    /**
     * 机器ID所占位数
     */
    @ApiModelProperty(value = "机器位数")
    public static final long MACHINE_ID_BITS = 5L;

    /**
     * 机器ID最大值31，0-31
     */
    @ApiModelProperty(value = "机器ID最大")
    public static final long MAX_MACHINE_ID = ~(-1L << MACHINE_ID_BITS);

    /**
     * 数据中心ID所占位数
     */
    @ApiModelProperty(value = "数据中心ID所占位数")
    public static final long DATACENTER_ID_BITS = 5L;

    /**
     * 数据中心ID最大值31，0-31
     */
    @ApiModelProperty(value = "数据中心ID最大值")
    public static final long MAX_DATACENTER_ID = ~(-1L << MACHINE_ID_BITS);

    /**
     * Sequence所占位数
     */
    @ApiModelProperty(value = "序列所占位数")
    public static final long SEQUENCE_BITS = 12L;

    /**
     * 机器ID偏移量12
     */
    @ApiModelProperty(value = "机器ID偏移量")
    public static final long MACHINE_SHIFT_BITS = SEQUENCE_BITS;

    /**
     * 数据中心ID偏移量12+5=17
     */
    @ApiModelProperty(value = "数据中心ID偏移量")
    public static final long DATACENTER_SHIFT_BITS = SEQUENCE_BITS + MACHINE_ID_BITS;

    /**
     * 时间戳的偏移量12+5+5=22
     */
    @ApiModelProperty(value = "时间戳偏移量")
    public static final long TIMESTAMP_LEFT_SHIFT_BITS = SEQUENCE_BITS + MACHINE_ID_BITS + DATACENTER_ID_BITS;

    /**
     * Sequence掩码4095
     */
    @ApiModelProperty(value = "序列掩码")
    public static final long SEQUENCE_MASK = ~(-1L << SEQUENCE_BITS);

    /**
     * 机器ID掩码1023
     */
    @ApiModelProperty(value = "机器ID掩码")
    public static final long MACHINE_MASK = ~(-1L << MACHINE_ID_BITS);

    /**
     * 数据中心掩码1023
     */
    @ApiModelProperty(value = "数据中心掩码")
    public static final long DATACENTER_MASK = ~(-1L << MACHINE_ID_BITS);

    /**
     * 时间戳掩码2的41次方减1
     */
    @ApiModelProperty(value = "时间戳掩码")
    public static final long TIMESTAMP_MASK = ~(-1L << 41L);

}
