Interface Equalator<T>

Type Parameters:
T - type of objects to compare
All Known Subinterfaces:
HashEqualator<T>, HashEqualator.IdentityHashEqualator<E>, HashEqualator.ImmutableHashEqualator<E>, HashEqualator.ImmutableValueTypeHashEqualator<E>, HashEqualator.ValueTypeHashEqualator<E>, IdentityEqualator<E>, ValueTypeEqualator<E>
All Known Implementing Classes:
Equalator.ComparatorWrapper, Equalator.Sequence, PersistenceTypeDescriptionMember.IdentityHashEqualator, TypePair.HashEquality

public interface Equalator<T>
A equalator function which checks if two given objects are equal or not. Since it is very close to the Comparator, but has limited return value, it is possible to wrap an existing comparator with the Wrap(Comparator) method.
  • Method Details

    • equal

      boolean equal​(T object1, T object2)
      Compares the two given objects (object1 and object2) depending on the implementation.
      Parameters:
      object1 - as first object to check equality on
      object2 - as second object to check equality on
      Returns:
      true if object1 equals object2, false if not.
    • sample

      default Predicate<T> sample​(T sample)
      Creates a Predicate that checks every given object with equality against the set sample.
      Parameters:
      sample - which is compared
      Returns:
      function that compares the input of the function with the given sample
    • Wrap

      static <E> Equalator<E> Wrap​(Comparator<? super E> comparator)
      Wraps a given Comparator into an Equalator. Resulting Equalator returns true if the comparator return 0. In all other cases false is returned.
      Type Parameters:
      E - type of objects to compare
      Parameters:
      comparator - to wrap insinde a new Equalator
      Returns:
      a new Equalator which executes the given comparator
    • Chain

      @SafeVarargs static <E> Equalator<E> Chain​(Equalator<? super E>... equalators)
      Type Parameters:
      E - type of objects to compare
      Parameters:
      equalators - to chain together
      Returns:
      Chained Equalator and only if all Equalators return true, this created Equalator returns true.
    • value

      static <E> Equalator<E> value()
      Type Parameters:
      E - type of objects to compare
      Returns:
      Static equalator which defines equality through the Object.equals(Object) method.
    • identity

      static <E> Equalator<E> identity()
      Type Parameters:
      E - type of objects to compare
      Returns:
      Static equalator which defines equality through the '=='-Operator.