package space.nstart.pcp.pcp_satellites_service.service

import org.springframework.stereotype.Service
import space.nstart.pcp.pcp_satellites_service.configuration.CustomValidationException
import space.nstart.pcp.pcp_types_lib.dto.requests.CoverageCalculationSource

@Service
class CoverageCalculationClientResolver(
    clients: List<CoverageCalculationClient>
) {
    private val clientsBySource = clients.associateBy { it.source }

    fun resolve(source: CoverageCalculationSource): CoverageCalculationClient =
        clientsBySource[source]
            ?: throw CustomValidationException("Unsupported coverage calculation source: $source")
}
