from logging import Logger

from production.box import OrderPropertiesFilterBox
from production.treebuilder import BoxConfiguration
from typing import Dict

from ._BoxBuilder import BoxBuilder


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

        super(OrderPropertiesFilterBoxBuilder, self).__init__(loggers)

    def build(
            self,
            config  # type: BoxConfiguration
    ):
        # type: (...) -> OrderPropertiesFilterBoxBuilder

        return OrderPropertiesFilterBox(
            config.name,
            config.sons,
            self.get_extra(config, "OrderProperty", ""),
            self.get_extra(config, "AllowedValues", []),
            self.get_extra(config, "ExcludedValues", []),
            self.get_extra(config, "RemoveOrder", True),
            self.get_logger(config)
        )
