package com.ningdatech.carapi.driver.constant;

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

import java.util.Objects;

/**
 * 驾驶员是否能够参加培训报名-枚举
 * @return
 * @author CMM
 * @since 2023/02/15 16:03
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "TrainingRegistrationFlagEnum", description = "驾驶员是否能够参加培训报名-枚举")
public enum TrainingRegistrationFlagEnum {
    CAN_NOT_TAKE(0, "false"),

    CAN_TAKE(1, "true");

    private Integer code;
    private String desc;


    public String getDesc() {
        return desc;
    }

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

    public static String getDescByCode(int code) {
        if(Objects.isNull(code)){
            return StringUtils.EMPTY;
        }
        for (TrainingRegistrationFlagEnum t : TrainingRegistrationFlagEnum.values()) {
            if (code == t.getCode()) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

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