package com.ycwl.basic.puzzle.fill.enums;

import lombok.Getter;

/**
 * 填充规则条件类型枚举
 */
@Getter
public enum ConditionType {

    /**
     * 机位数量匹配
     */
    DEVICE_COUNT("DEVICE_COUNT", "机位数量匹配"),

    /**
     * 机位ID精确匹配
     */
    DEVICE_ID_MATCH("DEVICE_ID_MATCH", "机位ID精确匹配"),

    /**
     * 总是匹配(兜底规则)
     */
    ALWAYS("ALWAYS", "总是匹配");

    private final String code;
    private final String description;

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

    /**
     * 根据code获取枚举
     */
    public static ConditionType fromCode(String code) {
        for (ConditionType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的条件类型: " + code);
    }
}
