package com.sky.ioc.tool;

import com.alibaba.fastjson.JSONObject;
import com.sky.ioc.entity.Label;
import org.apache.poi.ss.formula.functions.T;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
 * TODO
 *
 * @Description  通用方法
 * @Author LunCe
 * @Date 2023/3/9 11:42
 **/
public class GeneralMethod {

    private volatile static GeneralMethod instance;

    private GeneralMethod(){}

    public static GeneralMethod getInstance(){
        if (instance == null){
            synchronized (GeneralMethod.class){
                if (instance == null){
                    instance = new GeneralMethod();
                }
            }
        }
        return instance;
    }



    public List<Label> dataGeneration(String[] paramSize, String[] labKey){
        List<Label> list = new ArrayList<>();
        ThreadLocalRandom random = ThreadLocalRandom.current();
        for (int i = 0; i < labKey.length; i++) {
            Label label = new Label();
            JSONObject jsonObject = new JSONObject();
            for (int j = 0; j < paramSize.length; j++) {
                int i1 = random.nextInt(50, 150);
                jsonObject.put(paramSize[j],i1);
            }
            label.setJsonObject(jsonObject);
            label.setLabel(labKey[i]);
            list.add(label);
        }
        return list;
    }

}
