Skip to content

AbstractDiffer

Bases: ABC

Source code in library_analyzer/processing/migration/model/_differ.py
@dataclass
class AbstractDiffer(ABC):
    previous_base_differ: Optional[AbstractDiffer]
    previous_mappings: list[Mapping]
    apiv1: API
    apiv2: API

    @abstractmethod
    def compute_attribute_similarity(
        self,
        attributev1: Attribute,
        attributev2: Attribute,
    ) -> float:
        """
        Computes similarity between attributes from apiv1 and apiv2.
        :param attributev1: attribute from apiv1
        :param attributev2: attribute from apiv2
        :return: value between 0 and 1, where 1 means that the elements are equal
        """

    @abstractmethod
    def compute_class_similarity(self, classv1: Class, classv2: Class) -> float:
        """
        Computes similarity between classes from apiv1 and apiv2.
        :param classv1: class from apiv1
        :param classv2: class from apiv2
        :return: value between 0 and 1, where 1 means that the elements are equal
        """

    @abstractmethod
    def compute_function_similarity(
        self, functionv1: Function, functionv2: Function
    ) -> float:
        """
        Computes similarity between functions from apiv1 and apiv2.
        :param functionv1: function from apiv1
        :param functionv2: function from apiv2
        :return: value between 0 and 1, where 1 means that the elements are equal
        """

    @abstractmethod
    def compute_parameter_similarity(
        self, parameterv1: Parameter, parameterv2: Parameter
    ) -> float:
        """
        Computes similarity between parameters from apiv1 and apiv2.
        :param parameterv1: parameter from apiv1
        :param parameterv2: parameter from apiv2
        :return: value between 0 and 1, where 1 means that the elements are equal
        """

    @abstractmethod
    def compute_result_similarity(self, resultv1: Result, resultv2: Result) -> float:
        """
        Computes similarity between results from apiv1 and apiv2.
        :param resultv1: result from apiv1
        :param resultv2: result from apiv2
        :return: value between 0 and 1, where 1 means that the elements are equal
        """

    @abstractmethod
    def get_related_mappings(
        self,
    ) -> Optional[list[Mapping]]:
        """
        Indicates whether all api elements should be compared with each other
        or just the ones that are mapped to each other.
        :return: a list of Mappings if only previously mapped api elements should be mapped to each other or else None.
        """

    @abstractmethod
    def notify_new_mapping(self, mappings: list[Mapping]) -> None:
        """
        If previous mappings returns None, the differ will be notified about a new mapping.
        Thereby the differ can calculate the similarity with more information.
        :param mappings: a list of mappings new appended mappings.
        """

    @abstractmethod
    def get_additional_mappings(self) -> list[Mapping]:
        """
        This method allows the differ to add further mappings from previous differs
        :return: additional mappings that should be included in the result of the differentiation
        """

apiv1: API class-attribute

apiv2: API class-attribute

previous_base_differ: Optional[AbstractDiffer] class-attribute

previous_mappings: list[Mapping] class-attribute

compute_attribute_similarity(attributev1, attributev2) abstractmethod

Computes similarity between attributes from apiv1 and apiv2. :param attributev1: attribute from apiv1 :param attributev2: attribute from apiv2 :return: value between 0 and 1, where 1 means that the elements are equal

Source code in library_analyzer/processing/migration/model/_differ.py
@abstractmethod
def compute_attribute_similarity(
    self,
    attributev1: Attribute,
    attributev2: Attribute,
) -> float:
    """
    Computes similarity between attributes from apiv1 and apiv2.
    :param attributev1: attribute from apiv1
    :param attributev2: attribute from apiv2
    :return: value between 0 and 1, where 1 means that the elements are equal
    """

compute_class_similarity(classv1, classv2) abstractmethod

Computes similarity between classes from apiv1 and apiv2. :param classv1: class from apiv1 :param classv2: class from apiv2 :return: value between 0 and 1, where 1 means that the elements are equal

Source code in library_analyzer/processing/migration/model/_differ.py
@abstractmethod
def compute_class_similarity(self, classv1: Class, classv2: Class) -> float:
    """
    Computes similarity between classes from apiv1 and apiv2.
    :param classv1: class from apiv1
    :param classv2: class from apiv2
    :return: value between 0 and 1, where 1 means that the elements are equal
    """

compute_function_similarity(functionv1, functionv2) abstractmethod

Computes similarity between functions from apiv1 and apiv2. :param functionv1: function from apiv1 :param functionv2: function from apiv2 :return: value between 0 and 1, where 1 means that the elements are equal

Source code in library_analyzer/processing/migration/model/_differ.py
@abstractmethod
def compute_function_similarity(
    self, functionv1: Function, functionv2: Function
) -> float:
    """
    Computes similarity between functions from apiv1 and apiv2.
    :param functionv1: function from apiv1
    :param functionv2: function from apiv2
    :return: value between 0 and 1, where 1 means that the elements are equal
    """

compute_parameter_similarity(parameterv1, parameterv2) abstractmethod

Computes similarity between parameters from apiv1 and apiv2. :param parameterv1: parameter from apiv1 :param parameterv2: parameter from apiv2 :return: value between 0 and 1, where 1 means that the elements are equal

Source code in library_analyzer/processing/migration/model/_differ.py
@abstractmethod
def compute_parameter_similarity(
    self, parameterv1: Parameter, parameterv2: Parameter
) -> float:
    """
    Computes similarity between parameters from apiv1 and apiv2.
    :param parameterv1: parameter from apiv1
    :param parameterv2: parameter from apiv2
    :return: value between 0 and 1, where 1 means that the elements are equal
    """

compute_result_similarity(resultv1, resultv2) abstractmethod

Computes similarity between results from apiv1 and apiv2. :param resultv1: result from apiv1 :param resultv2: result from apiv2 :return: value between 0 and 1, where 1 means that the elements are equal

Source code in library_analyzer/processing/migration/model/_differ.py
@abstractmethod
def compute_result_similarity(self, resultv1: Result, resultv2: Result) -> float:
    """
    Computes similarity between results from apiv1 and apiv2.
    :param resultv1: result from apiv1
    :param resultv2: result from apiv2
    :return: value between 0 and 1, where 1 means that the elements are equal
    """

get_additional_mappings() abstractmethod

This method allows the differ to add further mappings from previous differs :return: additional mappings that should be included in the result of the differentiation

Source code in library_analyzer/processing/migration/model/_differ.py
@abstractmethod
def get_additional_mappings(self) -> list[Mapping]:
    """
    This method allows the differ to add further mappings from previous differs
    :return: additional mappings that should be included in the result of the differentiation
    """

Indicates whether all api elements should be compared with each other or just the ones that are mapped to each other. :return: a list of Mappings if only previously mapped api elements should be mapped to each other or else None.

Source code in library_analyzer/processing/migration/model/_differ.py
@abstractmethod
def get_related_mappings(
    self,
) -> Optional[list[Mapping]]:
    """
    Indicates whether all api elements should be compared with each other
    or just the ones that are mapped to each other.
    :return: a list of Mappings if only previously mapped api elements should be mapped to each other or else None.
    """

notify_new_mapping(mappings) abstractmethod

If previous mappings returns None, the differ will be notified about a new mapping. Thereby the differ can calculate the similarity with more information. :param mappings: a list of mappings new appended mappings.

Source code in library_analyzer/processing/migration/model/_differ.py
@abstractmethod
def notify_new_mapping(self, mappings: list[Mapping]) -> None:
    """
    If previous mappings returns None, the differ will be notified about a new mapping.
    Thereby the differ can calculate the similarity with more information.
    :param mappings: a list of mappings new appended mappings.
    """