from production.model import Item
from typing import Any

from ._AllowedForbiddenFilter import AllowedForbiddenFilter
from ._OrderChangerProductionBox import OrderChangerProductionBox


def item_properties_retriever(item):
    # type: (Item) -> Any
    ret = []
    for p in item.properties:
        ret.append(p)

    return ret


class ItemPropertiesFilterBox(OrderChangerProductionBox):
    def __init__(self, name, sons, allowed_properties, forbidden_properties, allow_combos, logger=None):
        super(ItemPropertiesFilterBox, self).__init__(name, sons, logger)
        self.allowed_forbidden_filter = AllowedForbiddenFilter(allowed_properties, forbidden_properties, allow_combos)

    def change_order(self, order):
        return self.allowed_forbidden_filter.filter_items(order, item_properties_retriever)
