package com.ycwl.basic.service.pc.strategy.impl;

import com.ycwl.basic.service.pc.strategy.RematchContext;
import com.ycwl.basic.service.pc.strategy.RematchModeStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 重匹配模式5策略
 * 条件: hasLowThreshold || (ruleMatched >= 2)
 * 触发低阈值或匹配2个及以上规则即可重匹配
 *
 * @author longbinbin
 * @date 2025-01-31
 */
@Slf4j
@Component
public class RematchMode5Strategy implements RematchModeStrategy {

    @Override
    public boolean shouldRematch(RematchContext context) {
        boolean result = context.isHasLowThreshold()
                || context.getRuleMatched() >= 2;

        log.debug("RematchMode5Strategy判断: hasLowThreshold={}, ruleMatched={}, result={}",
                context.isHasLowThreshold(), context.getRuleMatched(), result);

        return result;
    }

    @Override
    public int getMode() {
        return 5;
    }
}
