package com.qqchen.deploy.backend.framework.monitor.impl;

import com.qqchen.deploy.backend.framework.monitor.AbstractServerThresholdChecker;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;

/**
 * 磁盘阈值检测器
 * Framework 提供的磁盘使用率检测能力
 * 
 * 通过函数式接口传入取值逻辑，实现通用性
 *
 * @author qqchen
 * @since 2025-12-07
 */
@Slf4j
public class DiskThresholdChecker<T> extends AbstractServerThresholdChecker<T> {
    
    private final java.util.function.Function<T, BigDecimal> valueExtractor;
    
    public DiskThresholdChecker(java.util.function.Function<T, BigDecimal> valueExtractor) {
        this.valueExtractor = valueExtractor;
    }
    
    @Override
    public BigDecimal getCurrentValue(T monitorData) {
        return monitorData != null ? valueExtractor.apply(monitorData) : null;
    }
    
    @Override
    public String getResourceInfo(T monitorData) {
        return "磁盘使用率";
    }
}
