package com.engine.salary.enums.salarybill;

import com.engine.salary.enums.BaseEnum;

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

/**
 * 工资单限制月份类型
 * <p>Copyright: Copyright (c) 2024</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public enum MonthTypeEnum implements BaseEnum<Integer> {

    SALARY_DATE(0, "薪资所属月", 93286),
    SEND_DATE(1, "发放日期", 93212);

    private int value;

    private String defaultLabel;

    private int labelId;

    MonthTypeEnum(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 String getDefaultLabelByValue(Integer value) {
        if (value == null) {
            return "";
        }
        MonthTypeEnum[] enumAry = MonthTypeEnum.values();
        for(int i = 0; i < Arrays.asList(enumAry).size(); i++){
            if (Integer.valueOf(enumAry[i].getValue()).equals(value)) {
                return enumAry[i].getDefaultLabel();
            }
        }
        return "";
    }

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

    public static MonthTypeEnum parseByValue(int value) {
        for (MonthTypeEnum e : MonthTypeEnum.values()) {
            if (Objects.equals(e.getValue(), value)) {
                return e;
            }
        }
        return SALARY_DATE;
    }
}
