Class EquivalenceTester<T>


  • @GwtCompatible
    @NullMarked
    public final class EquivalenceTester<T>
    extends java.lang.Object
    Tester for Equivalence relationships between groups of objects.

    To use, create a new EquivalenceTester and add equivalence groups where each group contains objects that are supposed to be equal to each other. Objects of different groups are expected to be unequal. For example:

    Note that testing Object.equals(Object) is more simply done using the EqualsTester. It includes an extra test against an instance of an arbitrary class without having to explicitly add another equivalence group.

    Since:
    10.0
    Author:
    Gregory Kick
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      EquivalenceTester<T> addEquivalenceGroup​(java.lang.Iterable<T> group)
      Adds a group of objects that are supposed to be equivalent to each other and not equivalent to objects in any other equivalence group added to this tester.
      EquivalenceTester<T> addEquivalenceGroup​(T first, T... rest)
      Adds a group of objects that are supposed to be equivalent to each other and not equivalent to objects in any other equivalence group added to this tester.
      static <T> EquivalenceTester<T> of​(com.google.common.base.Equivalence<? super T> equivalence)  
      EquivalenceTester<T> test()
      Run tests on equivalence methods, throwing a failure on an invalid test
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • of

        public static <T> EquivalenceTester<T> of​(com.google.common.base.Equivalence<? super T> equivalence)
      • addEquivalenceGroup

        @CanIgnoreReturnValue
        public EquivalenceTester<T> addEquivalenceGroup​(T first,
                                                        T... rest)
        Adds a group of objects that are supposed to be equivalent to each other and not equivalent to objects in any other equivalence group added to this tester.
      • addEquivalenceGroup

        @CanIgnoreReturnValue
        public EquivalenceTester<T> addEquivalenceGroup​(java.lang.Iterable<T> group)
        Adds a group of objects that are supposed to be equivalent to each other and not equivalent to objects in any other equivalence group added to this tester.
      • test

        @CanIgnoreReturnValue
        public EquivalenceTester<T> test()
        Run tests on equivalence methods, throwing a failure on an invalid test