from parallels.core.utils.entity import Entity


class ThirdpartyPackage(Entity):
    """Description of thirdparty package - its name, version and other parameters"""
    def __init__(
            self, package_name, package_version, executable, is_self_extractable=False, is_available_for_all=False
    ):
        """Class constructor

        :type package_name: str | unicode
        :type package_version: str | unicode
        :type executable: str | unicode
        :type is_self_extractable: bool
        """
        self._package_name = package_name
        self._package_version = package_version
        self._executable = executable
        self._is_self_extractable = is_self_extractable
        self._is_available_for_all = is_available_for_all

    @property
    def package_name(self):
        """Package name

        :rtype: str | unicode
        """
        return self._package_name

    @property
    def package_version(self):
        """Package version (as string)

        :rtype: str | unicode
        """
        return self._package_version

    @property
    def executable(self):
        """Executable file - entry point of the package

        :rtype: str | unicode | None
        """
        return self._executable

    @property
    def is_self_extractable(self):
        """Type of the package

        :rtype: bool
        """
        return self._is_self_extractable

    @property
    def available_for_all(self):
        """If planned to use thirdparty component on behalf of different users on local server,
         this property should be set to True.
         Enabling of the property will slightly affect performance:
         additional time will be spent to set proper file permissions.

        :rtype: bool
        """
        return self._is_available_for_all

    def __hash__(self):
        return hash((
            self.package_name, self.package_version, self.executable, self._is_self_extractable,
            self._is_available_for_all
        ))
