Class RecursiveComparator

  • All Implemented Interfaces:
    java.util.Comparator<java.lang.Object>

    public class RecursiveComparator
    extends java.lang.Object
    implements java.util.Comparator<java.lang.Object>
    Comparator comparing objects recursively as in RecursiveComparisonAssert.

    This comparator does not enforce any ordering and returns zero if the compared objects are equals, according to the recursive comparison, or a non-zero value otherwise.

    Since:
    3.24.0
    • Constructor Detail

      • RecursiveComparator

        public RecursiveComparator()
        Returns a new RecursiveComparator that uses the default RecursiveComparisonConfiguration when comparing objects with the recursive comparison.
        Since:
        3.25.0
      • RecursiveComparator

        public RecursiveComparator​(RecursiveComparisonConfiguration recursiveComparisonConfiguration)
        Returns a new RecursiveComparator that uses the given RecursiveComparisonConfiguration when comparing objects with the recursive comparison.
        Parameters:
        recursiveComparisonConfiguration - the RecursiveComparisonConfiguration instance to be used
    • Method Detail

      • determineDifferencesWith

        private java.util.List<ComparisonDifference> determineDifferencesWith​(java.lang.Object actual,
                                                                              java.lang.Object expected)
      • getDescription

        public java.lang.String getDescription()
      • compare

        public int compare​(java.lang.Object actual,
                           java.lang.Object other)
        Returns zero if the arguments are recursively equal to each other, or non-zero otherwise (no ordering enforced).
        Specified by:
        compare in interface java.util.Comparator<java.lang.Object>
        Parameters:
        actual - the object to compare to other
        other - the object to compare to actual
        Returns:
        zero if the arguments are recursively equal to each other, or non-zero otherwise.