package com.engine.salary.enums;


import java.util.Arrays;
import java.util.Objects;

/**
 * 字段类型
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public enum SalaryValueTypeEnum implements BaseEnum<Integer> {

    INPUT(1, "输入", 84976),
    FORMULA(2, "公式", 84977),
    SQL(3, "SQL", 84977);

    private int value;

    private String defaultLabel;

    private int labelId;

    SalaryValueTypeEnum(int value, String defaultLabel, int labelId) {
        this.value = value;
        this.defaultLabel = defaultLabel;
        this.labelId = labelId;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public String getDefaultLabel() {
        return defaultLabel;
    }

    @Override
    public Integer getLabelId() {
        return labelId;
    }

    public static SalaryValueTypeEnum parseByValue(int value) {
        for (SalaryValueTypeEnum salaryValueTypeEnum : SalaryValueTypeEnum.values()) {
            if (Objects.equals(salaryValueTypeEnum.getValue(), value)) {
                return salaryValueTypeEnum;
            }
        }
        return null;
    }


    public static String getDefaultLabelByValue(Integer value) {
        if (value == null) {
            return "";
        }
        SalaryValueTypeEnum[] enumAry = SalaryValueTypeEnum.values();
        for (int i = 0; i < Arrays.asList(enumAry).size(); i++) {
            if (Integer.valueOf(enumAry[i].getValue()).equals(value)) {
                return enumAry[i].getDefaultLabel();
            }
        }
        return "";
    }
}
