Class IterableElementComparisonStrategy<T>

All Implemented Interfaces:
ComparisonStrategy

public class IterableElementComparisonStrategy<T> extends StandardComparisonStrategy
  • Field Details

    • elementComparator

      private final Comparator<? super T> elementComparator
  • Constructor Details

    • IterableElementComparisonStrategy

      public IterableElementComparisonStrategy(Comparator<? super T> elementComparator)
  • Method Details

    • areEqual

      public boolean areEqual(Object actual, Object other)
      Description copied from class: StandardComparisonStrategy
      Returns true if the arguments are deeply equal to each other, false otherwise.

      It mimics the behavior of Objects.deepEquals(Object, Object), but without performing a reference check between the two arguments. According to deepEquals javadoc, the reference check should be delegated to the equals method of the first argument, but this is not happening. Bug JDK-8196069 also mentions this gap.

      Specified by:
      areEqual in interface ComparisonStrategy
      Overrides:
      areEqual in class StandardComparisonStrategy
      Parameters:
      actual - the object to compare to other
      other - the object to compare to actual
      Returns:
      true if the arguments are deeply equal to each other, false otherwise
      See Also:
    • compareElementsOf

      private boolean compareElementsOf(Iterable<T> actual, Iterable<T> other)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asText

      public String asText()
      Description copied from interface: ComparisonStrategy
      Used in error messages when a custom comparison strategy was used to compare values.

      For example ComparatorBasedComparisonStrategy returns:

      "when comparing values using " + toString()
      Returns:
      the comparison strategy description used in error messages.
    • isStandard

      public boolean isStandard()
      Description copied from interface: ComparisonStrategy
      Return true if comparison strategy is default/standard, false otherwise
      Specified by:
      isStandard in interface ComparisonStrategy
      Overrides:
      isStandard in class StandardComparisonStrategy
      Returns:
      true if comparison strategy is default/standard, false otherwise