package com.diagbot.idc;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: ID生成抽象类接口
 * @author: gaodm
 * @time: 2018/9/5 9:20
 */
public abstract class AbstractIdCreater<T> implements IdCreater<T> {

    protected int machineId;
    protected int dataCenterId;

    public AbstractIdCreater(int machineId, int dataCenterId) {
        this.machineId = machineId;
        this.dataCenterId = dataCenterId;
    }

    @Override
    public abstract Long getNextId(T param);

    @Override
    public List<Long> getNextIds(T param, int size) {
        List<Long> longs = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            longs.add(getNextId(param));
        }
        return longs;
    }

    protected long timeGen() {
        return System.currentTimeMillis();
    }
}
