Class Equal<T>

java.lang.Object
com.github.tonivade.purefun.core.Equal<T>
Type Parameters:
T - type to which it applies

public final class Equal<T> extends Object
This is a utility class to generate more readable equals() methods. It's based on Eq instances and it can combine some of them to generate a bigger function that verify the equivalence between two instances of the same type T.
  @Override
 public boolean equals(Object obj) {
   return<Equal.Data>of()
     .comparing(Data::getId)
     .comparing(Data::getValue)
     .applyTo(this, obj);
 }
  • Field Details

    • tester

      private final Eq<T> tester
  • Constructor Details

    • Equal

      private Equal(Eq<T> tester)
  • Method Details

    • append

      public Equal<T> append(Eq<T> other)
    • comparing

      public <V> Equal<T> comparing(Function1<T,V> getter)
    • comparingArray

      public <V> Equal<T> comparingArray(Function1<T,V[]> getter)
    • applyTo

      public boolean applyTo(T self, Object obj)
    • areEquals

      private boolean areEquals(T self, T other)
    • sameClasses

      private boolean sameClasses(T self, Object obj)
    • sameObjects

      private boolean sameObjects(T self, Object obj)
    • of

      public static <T> Equal<T> of()