Package org.revapi

Interface CorrespondenceComparatorDeducer<E extends Element<E>>

  • public interface CorrespondenceComparatorDeducer<E extends Element<E>>
    A correspondence comparator deducer produces a comparator that is used to compare elements from 2 collections.

    This is important in situations where the choice of the API comparison "partner" element cannot be determined without knowing its "neighborhood" in both element forests. A concrete example of this is comparison of overloaded methods.

    Lukas Krejci
    • Method Detail

      • editDistance

        static <E extends Element<E>> CorrespondenceComparatorDeducer<E> editDistance​(BiPredicate<? super E,​? super E> equality)
        This correspondence deducer is a good match for situations where the ordering of the children of some element is not semantic but rather positional, e.g. method parameters or elements of an array. The deducer will then return a comparator that will make Revapi produce the minimal set of changes necessary to transform the old into the new.
        Type Parameters:
        E - the base type of the elements
        equality - a function to determine the element equality
        a correspondence comparator deducer that will produce a diff-like ordering of the elements
      • sortAndGetCorrespondenceComparator

        Comparator<? super E> sortAndGetCorrespondenceComparator​(List<E> first,
                                                                 List<E> second)
        Deduces the correspondence comparator and sorts the provided lists so that the comparator, when used to compare the elements for the two lists mutually is consistent.

        The collections will contain elements of different types (which is consistent with how ElementForest stores the children) and it is assumed that the sorter is able to pick and choose which types of elements it is able to sort. The collections will be sorted according the natural order of the elements when entering this method.

        first - the first collection of elements
        second - the second collection of elements