package com.ningdatech.pmapi.todocenter.enumeration;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 是否增补项目枚举
 *
 * @author CMM
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "IsAppendProjectEnum", description = "是否增补项目-枚举")
public enum IsAppendProjectEnum {
    /**
     * 非增补项目
     */
    NOT_APPEND_PROJECT(0, "非增补项目"),

    /**
     * 增补项目
     */
    APPEND_PROJECT(1, "增补项目");


    private Integer code;
    private String desc;

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static String getDescByCode(Integer code) {
        if (Objects.isNull(code)) {
            return StringUtils.EMPTY;
        }
        for (IsAppendProjectEnum t : IsAppendProjectEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public static IsAppendProjectEnum getEnumByValue(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        for (IsAppendProjectEnum t : IsAppendProjectEnum.values()) {
            if (code.equals(t.getCode())) {
                return t;
            }
        }
        return null;
    }

    public boolean eq(String val) {
        return this.name().equals(val);
    }
}
