from typing import Dict

class Table:
    def __init__(self, use_case: str, name: str, mappings: Dict[str, str]):
        self.use_case = use_case
        self.name = name
        self.mappings = mappings

    def to_serializable_dict(self) -> Dict:
        return {
            "name": self.name, 
            "use_case": self.use_case,
            "mappings": self.mappings
        }
    
    def add_mapping(self, internal:str, external:str):
        if internal not in self.mappings.keys():
            self.mappings[internal] = external

    @staticmethod
    def from_serializable_dict(data: Dict):
        return Table(
            data["use_case"],
            data["name"],
            data["mappings"]
        )
