from typing import (
    Callable,
    Dict,
    Generic,
    TypeVar,
)

from edpconfigprovider import ConfigProvider

T = TypeVar("T")


class ConfigMapper(Generic[T]):
    def __init__(
        self,
        config_provider: ConfigProvider,
        transform_method: Callable[[Dict], T],
    ) -> None:
        self.config_provider = config_provider
        self.transform_method = transform_method

    def build_config(self) -> T:
        configuration_data = self.config_provider.get_configuration()
        return self.transform_method(configuration_data)
