package com.lingniu.ingest.eventhistory;

import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;

import java.util.Locale;
import java.util.Set;

final class DefaultProductionProtocols {

    private static final Set<String> SUPPORTED = Set.of(
            "GB32960",
            "JT808",
            "MQTT_YUTONG");
    private static final String SUPPORTED_MESSAGE = "protocol must be one of GB32960, JT808, MQTT_YUTONG";

    private DefaultProductionProtocols() {
    }

    static String requireSupported(String protocol) {
        String normalized = protocol == null ? "" : protocol.trim().toUpperCase(Locale.ROOT);
        if (!SUPPORTED.contains(normalized)) {
            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, SUPPORTED_MESSAGE);
        }
        return normalized;
    }
}
