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, it just returns 0 if compared objects are equals according the recursive comparison and a non 0 value otherwise.

    This comparator honors the RecursiveComparisonConfiguration passed at construction time.

    • Constructor Detail

      • RecursiveComparator

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

      • determineDifferencesWith

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

        public int compare​(java.lang.Object actual,
                           java.lang.Object other)
        Returns 0 if the arguments are recursively equal to each other, a 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:
        0 if the arguments are recursively equal to each other, a non-zero otherwise.
      • getDescription

        public java.lang.String getDescription()