from abc import ABC, abstractmethod

from bclearer_orchestration_services.identification_services.b_identity_ecosystem.bie_id_creation_module.bie_id_creation_facade import (
    BieIdCreationFacade,
)
from bclearer_orchestration_services.identification_services.b_identity_ecosystem.bie_id_creation_module.identity_vectors import (
    BieIdentityVectorBase,
)


class BieObjects(ABC):
    def __init__(
        self,
        identity_vector: BieIdentityVectorBase,
    ):
        if identity_vector is None:
            raise ValueError(
                "BieObjects requires identity_vector"
            )

        self._identity_vector = (
            identity_vector
        )

        self.base_hr_name = (
            identity_vector.bie_hr_name
        )

        self.bie_type = (
            identity_vector.bie_domain_type
        )

        self.bie_id = BieIdCreationFacade.create_bie_id_from_identity_vector(
            vector=identity_vector,
        )

    def __hash__(self):
        return hash(
            self.bie_id.int_value
        )

    @abstractmethod
    def _create_vector(
        self,
    ) -> BieIdentityVectorBase:
        raise NotImplementedError(
            f"{type(self).__name__} does not implement _create_vector()"
        )
