package com.sckw.transport.model.enuma;

import lombok.Getter;

/**
 * @author cxf
 * @desc 车辆异常类型枚举
 * @date 2025-12-01
 */
@Getter
public enum VehicleExceptionTypeEnum {
    /**
     * 正常
     */
    NORMAL(0, "正常"),
    /**
     * 车辆偏航
     */
    DEVIATION(1, "车辆偏航"),
    
    /**
     * 急刹车
     */
    SUDDEN_BRAKE(2, "急刹车"),
    
    /**
     * 超速
     */
    OVERSPEED(3, "超速"),
    
    /**
     * 异常停车
     */
    ABNORMAL_PARKING(4, "异常停车");
    
    private final Integer code;
    private final String name;
    
    VehicleExceptionTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }
    
    public static String getName(Integer code) {
        for (VehicleExceptionTypeEnum entity : VehicleExceptionTypeEnum.values()) {
            if (entity.getCode().equals(code)) {
                return entity.getName();
            }
        }
        return null;
    }
    
    public static VehicleExceptionTypeEnum getByCode(Integer code) {
        for (VehicleExceptionTypeEnum entity : VehicleExceptionTypeEnum.values()) {
            if (entity.getCode().equals(code)) {
                return entity;
            }
        }
        return null;
    }
}
