package com.multictrl.common.utils.weather;

/**
 * 雪量工具类
 *
 * @author Sdy
 * @since 1.0.0 2025/10/13
 */
public class SnowUtils {
    // 小雪类天气现象
    public static final String[] LIGHT_SNOW_TYPES = {
            "雪",
            "阵雪",
            "小雪",
            "雨雪天气",
            "雨夹雪",
            "阵雨夹雪"
    };

    // 中雪类天气现象
    public static final String[] MODERATE_SNOW_TYPES = {
            "中雪",
            "小雪-中雪"
    };

    // 大雪类天气现象
    public static final String[] HEAVY_SNOW_TYPES = {
            "大雪",
            "暴雪",
            "中雪-大雪",
            "大雪-暴雪"
    };

    /**
     * 判断是否为小雪类
     */
    public static boolean isMinSnow(String snowType) {
        return contains(LIGHT_SNOW_TYPES, snowType);
    }

    /**
     * 判断是否为中雪类
     */
    public static boolean isModerateSnow(String snowType) {
        return contains(MODERATE_SNOW_TYPES, snowType);
    }

    /**
     * 判断是否为大雪类
     */
    public static boolean isMaxSnow(String snowType) {
        return contains(HEAVY_SNOW_TYPES, snowType);
    }

    /**
     * 获取雪类型所属的类别名称
     */
    public static String getCategory(String snowType) {
        if (isMinSnow(snowType)) return "小雪";
        if (isModerateSnow(snowType)) return "中雪";
        if (isMaxSnow(snowType)) return "大雪";
        return "未知";
    }

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