package com.ningdatech.carapi.common.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;

/**
 * 车辆是否行驶
 *
 * @author PoffyZhang
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "VehicleMovingEnum", description = "车辆是否行驶-枚举")
public enum VehicleMovingEnum {
    /**
     *
     */
    MOVING(1, "行驶中"),

    /**
     *离线
     */
    NOT_MOVING(0, "不在行驶");


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


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

}
