package com.ningdatech.carapi.common.constant;

import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 车辆在线状态
 *
 * @author PoffyZhang
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CarStatusEnum", description = "车辆状态-枚举")
public enum CarStatusEnum {
    /**
     * 启用
     */
    ENABLE(1, "启用"),

    /**
     *停用
     */
    DISABLE(2, "停用"),

    /**
     * 维修
     */
    REPAIR(3, "维修"),

    /**
     * 报废
     */
    SCRAP(4,"报废"),

    /**
     * 出售
     */
    SELL(5,"出售");


    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 (CarStatusEnum t : CarStatusEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

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

}
