from logging import Logger
from typing import Dict

from production.box import CustomPropertyValueFilterBox
from production.treebuilder import BoxConfiguration

from ._BoxBuilder import BoxBuilder


class CustomPropertyValueFilterBoxBuilder(BoxBuilder):
    def __init__(
        self,           # type: CustomPropertyValueFilterBoxBuilder
        loggers,        # type: Dict[str, Logger]
    ):
        # type (...) -> None

        super(CustomPropertyValueFilterBoxBuilder, self).__init__(loggers)

    def build(
        self,       # type: CustomPropertyValueFilterBoxBuilder
        config,     # type: BoxConfiguration
    ):
        # type: (BoxConfiguration) -> CustomPropertyValueFilterBox

        return CustomPropertyValueFilterBox(
            name=config.name,
            sons=config.sons,
            parameter_name=self.get_extra(config, "PropertyName", None),
            allowed_values=self.get_extra(config, "AllowedValues", None),
            excluded_values=self.get_extra(config, "ExcludedValues", None),
            logger=self.get_logger(config),
        )
