package com.gci.boot.enums;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author lyz
 * @date 2023/8/30 16:28
 */
public enum EventType {
    /**
     * 事件类型枚举
     */
    FORWARD_COLLISION(1, "前向碰撞报警"),
    LANE_DEPARTURE(2, "车道偏离报警"),
    CLOSE_DISTANCE(3, "车距过近报警"),
    PEDESTRIAN_COLLISION(4, "行人碰撞报警"),
    FREQUENT_LANE_CHANGE(5, "频繁变道报警"),
    ROAD_SIGN_OVERSIZE(6, "道路标识超限报警"),
    OBSTACLE(7, "障碍物报警"),
    ROAD_SIGN_RECOGNITION(8, "道路标志识别事件"),
    ACTIVE_CAPTURE(9, "主动抓拍事件"),
    FATIGUE_DRIVING(10, "疲劳驾驶报警"),
    PHONE_USE(11, "接打电话报警"),
    SMOKING(12, "抽烟报警"),
    DISTRACTED_DRIVING(13, "分神驾驶报警"),
    ABNORMAL_DRIVER(14, "驾驶员异常报警"),
    AUTOMATIC_CAPTURE(15, "自动抓拍事件"),
    DRIVER_CHANGE(16, "驾驶员变更事件"),
    DRIVER_STATUS_OTHER(98, "驾驶状态其它"),
    ADAS_OTHER(99, "辅助驾驶其它");

    private final int code;
    private final String description;

    EventType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public static String getName(int value) {
        EventType eventType = Arrays.stream(EventType.values()).filter(a -> {
            return a.code == value;
        }).findFirst().orElse(null);
        return Objects.nonNull(eventType) ? eventType.getDescription() : "";
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
