package com.multictrl.common.utils.weather;

/**
 * 霾量工具类
 *
 * @author Sdy
 * @since 1.0.0 2025/10/13
 */
public class HazeUtils {

    // 轻度霾类天气现象
    public static final String[] LIGHT_HAZE_TYPES = {
            "霾"
    };

    // 中度霾类天气现象
    public static final String[] MODERATE_HAZE_TYPES = {
            "中度霾"
    };

    // 重度霾类天气现象
    public static final String[] HEAVY_HAZE_TYPES = {
            "重度霾",
            "严重霾"
    };

    /**
     * 判断是否为轻度霾类
     */
    public static boolean isMinHaze(String hazeType) {
        return contains(LIGHT_HAZE_TYPES, hazeType);
    }

    /**
     * 判断是否为中度霾类
     */
    public static boolean isModerateHaze(String hazeType) {
        return contains(MODERATE_HAZE_TYPES, hazeType);
    }

    /**
     * 判断是否为重度霾类
     */
    public static boolean isMaxHaze(String hazeType) {
        return contains(HEAVY_HAZE_TYPES, hazeType);
    }

    /**
     * 获取霾类型所属的类别名称
     */
    public static String getCategory(String hazeType) {
        if (isMinHaze(hazeType)) return "轻度霾";
        if (isModerateHaze(hazeType)) return "中度霾";
        if (isMaxHaze(hazeType)) return "重度霾";
        return "未知";
    }

    /**
     * 检查字符串是否在数组中
     */
    private static boolean contains(String[] array, String value) {
        for (String item : array) {
            if (item.equals(value)) {
                return true;
            }
        }
        return false;
    }
}
