package com.usky.vpp.enums;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

/**
 * 设备类型与时序电量属性映射（用于月度电量核算）
 */
public enum DeviceTypeMetricEnum {

    /**
     * 充电桩 product/device_type = 809
     */
    EV_CHARGER_809(
            "809",
            Arrays.asList("epp1", "epp2", "epp3", "epp4", "epn1", "epn2", "epn3", "epn4", "epp", "epn")
    );

    private final String deviceType;
    private final List<String> metrics;

    DeviceTypeMetricEnum(String deviceType, List<String> metrics) {
        this.deviceType = deviceType;
        this.metrics = Collections.unmodifiableList(metrics);
    }

    public String getDeviceType() {
        return deviceType;
    }

    public List<String> getMetrics() {
        return metrics;
    }

    public static Optional<DeviceTypeMetricEnum> ofDeviceType(String deviceType) {
        if (deviceType == null || deviceType.trim().isEmpty()) {
            return Optional.empty();
        }
        String key = deviceType.trim();
        return Arrays.stream(values())
                .filter(item -> item.deviceType.equalsIgnoreCase(key))
                .findFirst();
    }
}
