Interface DeepComparator.ComparisonRule

Enclosing class:
DeepComparator

public static interface DeepComparator.ComparisonRule
This interface allows to define a class that will execute specific comparison. It's use in the #comparisonPredicates map, to define special behavior, including breaking cycles: if the A.b field is of class B, and the B.a field is of class A, then you can define specific comparison rule in the #comparisonPredicates map, so that when comparing the B.a field, you don't cycle back into the A class. This comparison can be a non operation method, or a any comparison of you own.
Author:
etienne-sf
  • Method Summary

    Modifier and Type
    Method
    Description
    compare(Object o1, Object o2, int nbMaxDifferences)
    Compares two objects, and returns the list of found difference.
  • Method Details

    • compare

      List<DeepComparator.Difference> compare(Object o1, Object o2, int nbMaxDifferences)
      Compares two objects, and returns the list of found difference.
      Parameters:
      o1 - may not be null (this will be checked before calling this method)
      o2 - may not be null (this will be checked before calling this method)
      nbMaxDifferences - The maximum number of differences to return. This allows to limit the size of the returned list, and to accelerate the comparison.
      Setting 1 here will stop as soon as a difference is found.
      Setting it to a negative value prevents any comparison to occur.
      Set it to Integer.MAX_VALUE to have (almost) no limit on the number of returned differences
      Returns:
      A non null list. If it's empty, then there is no difference between o1 and o2. The root path for the returned DeepComparator.Differences is this field, starting by a slash (/). If differences are returned by this method, they will be updated with the current path of the comparison when this method was called.