package com.rongwei.bsentity.enums;

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

/**
 * @author shangmi
 * @title MaintenanceTypeEnum
 * @date 2023/12/7 17:27
 * @description 保养分类数据字典
 */
public enum MaintenanceTypeEnum {
    MECHANICAL_OVERHAUL("机械检修","JJ"),
    ELECTRICAL_REPAIR("电气检修","DJ"),
    ENGINE_ATTENDANCE("机械保养","JY"),
    ELECTRICAL_MAINTENANCE("电气保养","DY")
    ;
    private final String type;
    private final String message;

    MaintenanceTypeEnum(String type,String message){
        this.message = message;
        this.type = type;
    }

    public static String  typeOf(String message){
        return getMessageByType(message,null).type;
    }

    public static String messageOf(String type){
        return getTypeByMessage(type,null).message;
    }

    public static MaintenanceTypeEnum getMessageByType(String message,MaintenanceTypeEnum maintenanceTypeEnum){
        return Arrays.stream(values()).filter(info -> Objects.equals(info.message, message)).findFirst().orElse(maintenanceTypeEnum);
    }


    private static MaintenanceTypeEnum getTypeByMessage(String type,MaintenanceTypeEnum maintenanceTypeEnum){
        return Arrays.stream(values()).filter(info -> type.equals(info.type)).findFirst().orElse(maintenanceTypeEnum);
    }
}
