Package fj

Class Equal<A>

java.lang.Object
fj.Equal<A>

public final class Equal<A> extends Object
Tests for equality between two objects.
  • Field Details

    • def

      private final Equal.Definition<A> def
    • booleanEqual

      public static final Equal<Boolean> booleanEqual
      An equal instance for the boolean type.
    • byteEqual

      public static final Equal<Byte> byteEqual
      An equal instance for the byte type.
    • charEqual

      public static final Equal<Character> charEqual
      An equal instance for the char type.
    • doubleEqual

      public static final Equal<Double> doubleEqual
      An equal instance for the double type.
    • floatEqual

      public static final Equal<Float> floatEqual
      An equal instance for the float type.
    • intEqual

      public static final Equal<Integer> intEqual
      An equal instance for the int type.
    • bigintEqual

      public static final Equal<BigInteger> bigintEqual
      An equal instance for the BigInteger type.
    • bigdecimalEqual

      public static final Equal<BigDecimal> bigdecimalEqual
      An equal instance for the BigDecimal type.
    • longEqual

      public static final Equal<Long> longEqual
      An equal instance for the long type.
    • shortEqual

      public static final Equal<Short> shortEqual
      An equal instance for the short type.
    • naturalEqual

      public static final Equal<Natural> naturalEqual
      An equal instance for the Natural type.
    • stringEqual

      public static final Equal<String> stringEqual
      An equal instance for the String type.
    • stringBufferEqual

      public static final Equal<StringBuffer> stringBufferEqual
      An equal instance for the StringBuffer type.
    • stringBuilderEqual

      public static final Equal<StringBuilder> stringBuilderEqual
      An equal instance for the StringBuilder type.
    • bitSetSequal

      public static final Equal<BitSet> bitSetSequal
      An equal instance for the BitSet type.
    • eq

      public static final Equal<LazyString> eq
      An equal instance for lazy strings.
    • hListEqual

      public static final Equal<HList.HNil> hListEqual
      An equal instance for the empty heterogeneous list.
  • Constructor Details

  • Method Details

    • eq

      public boolean eq(A a1, A a2)
      Returns true if the two given arguments are equal, false otherwise.
      Parameters:
      a1 - An object to test for equality against another.
      a2 - An object to test for equality against another.
      Returns:
      true if the two given arguments are equal, false otherwise.
    • notEq

      public boolean notEq(A a1, A a2)
      Returns true if the two given arguments are not equal, false otherwise.
      Parameters:
      a1 - An object to test for inequality against another.
      a2 - An object to test for inequality against another.
      Returns:
      true if the two given arguments are not equal, false otherwise.
    • eq

      public F2<A,A,Boolean> eq()
      First-class equality check.
      Returns:
      A function that returns true if the two given arguments are equal.
    • eq

      public F<A,Boolean> eq(A a)
      Partially applied equality check.
      Parameters:
      a - An object to test for equality against another.
      Returns:
      A function that returns true if the given argument equals the argument to this method.
    • contramap

      public <B> Equal<B> contramap(F<B,A> f)
      Maps the given function across this equal as a contra-variant functor.
      Parameters:
      f - The function to map.
      Returns:
      A new equal.
    • not

      public final Equal<A> not()
      An equal instance, which reverts equality for self
      Returns:
      A new equal instance
    • contramapDef

      private static <A, B> Equal.Definition<B> contramapDef(F<B,A> f, Equal.Definition<A> aEqDef)
    • contramap

      public static <A, B> Equal<A> contramap(F<A,B> f, Equal<B> eq)
      Static version of contramap(F)
    • on

      public static <A, B> Equal.Definition<A> on(F<A,B> f, Equal<B> eq)
      Begin definition of an equal instance.
      See Also:
    • equal

      public static <A> Equal<A> equal(F<A,F<A,Boolean>> f)
      Constructs an equal instance from the given function. Java 8+ users: use equalDef(Definition) instead.
      Parameters:
      f - The function to construct the equal with.
      Returns:
      An equal instance from the given function.
    • equal

      public static <A> Equal<A> equal(F2<A,A,Boolean> f)
      Constructs an equal instance from the given function. Java 8+ users: use equalDef(AltDefinition) instead.
      Parameters:
      f - The function to construct the equal with.
      Returns:
      An equal instance from the given function.
    • equalDef

      public static <A> Equal<A> equalDef(Equal.Definition<A> definition)
      Constructs an equal instance from the given definition.
      Parameters:
      definition - a definition of the equal instance.
      Returns:
      An equal instance from the given function.
    • equalDef

      public static <A> Equal<A> equalDef(Equal.AltDefinition<A> definition)
      Constructs an equal instance from the given (alternative) definition.
      Parameters:
      definition - a definition of the equal instance.
      Returns:
      An equal instance from the given function.
    • anyEqual

      public static <A> Equal<A> anyEqual()
      Returns an equal instance that uses the Object.equals(Object) method to test for equality.
      Returns:
      An equal instance that uses the Object.equals(Object) method to test for equality.
    • eitherEqual

      public static <A, B> Equal<Either<A,B>> eitherEqual(Equal<A> ea, Equal<B> eb)
      An equal instance for the Either type.
      Parameters:
      ea - Equality across the left side of Either.
      eb - Equality across the right side of Either.
      Returns:
      An equal instance for the Either type.
    • either3Equal

      public static <A, B, C> Equal<Either3<A,B,C>> either3Equal(Equal<A> ea, Equal<B> eb, Equal<C> ec)
    • resultEqual

      public static <I, A> Equal<Result<I,A>> resultEqual(Equal<A> ea, Equal<I> ei)
    • validationEqual

      public static <A, B> Equal<Validation<A,B>> validationEqual(Equal<A> ea, Equal<B> eb)
      An equal instance for the Validation type.
      Parameters:
      ea - Equality across the failing side of Validation.
      eb - Equality across the succeeding side of Validation.
      Returns:
      An equal instance for the Validation type.
    • listEqual

      public static <A> Equal<List<A>> listEqual(Equal<A> ea)
      An equal instance for the List type.
      Parameters:
      ea - Equality across the elements of the list.
      Returns:
      An equal instance for the List type.
    • nonEmptyListEqual

      public static <A> Equal<NonEmptyList<A>> nonEmptyListEqual(Equal<A> ea)
      An equal instance for the NonEmptyList type.
      Parameters:
      ea - Equality across the elements of the non-empty list.
      Returns:
      An equal instance for the NonEmptyList type.
    • optionEqual

      public static <A> Equal<Option<A>> optionEqual(Equal<A> ea)
      An equal instance for the Option type.
      Parameters:
      ea - Equality across the element of the option.
      Returns:
      An equal instance for the Option type.
    • seqEqual

      public static <A> Equal<Seq<A>> seqEqual(Equal<A> e)
    • streamEqual

      public static <A> Equal<Stream<A>> streamEqual(Equal<A> ea)
      An equal instance for the Stream type.
      Parameters:
      ea - Equality across the elements of the stream.
      Returns:
      An equal instance for the Stream type.
    • zipperEqual

      public static <A> Equal<Zipper<A>> zipperEqual(Equal<A> ea)
      An equal instance for the Zipper type.
      Parameters:
      ea - Equality across the elements of the zipper.
      Returns:
      An equal instance for the Zipper type.
    • treeZipperEqual

      public static <A> Equal<TreeZipper<A>> treeZipperEqual(Equal<A> ea)
      An equal instance for the TreeZipper type.
      Parameters:
      ea - Equality across the elements of the tree zipper.
      Returns:
      An equal instance for the TreeZipper type.
    • arrayEqual

      public static <A> Equal<Array<A>> arrayEqual(Equal<A> ea)
      An equal instance for the Array type.
      Parameters:
      ea - Equality across the elements of the array.
      Returns:
      An equal instance for the Array type.
    • treeEqual

      public static <A> Equal<Tree<A>> treeEqual(Equal<A> ea)
      An equal instance for the Tree type.
      Parameters:
      ea - Equality across the elements of the tree.
      Returns:
      An equal instance for the Tree type.
    • p1Equal

      public static <A> Equal<P1<A>> p1Equal(Equal<A> ea)
      An equal instance for a product-1.
      Parameters:
      ea - Equality across the first element of the product.
      Returns:
      An equal instance for a product-1.
    • p2Equal

      public static <A, B> Equal<P2<A,B>> p2Equal(Equal<A> ea, Equal<B> eb)
      An equal instance for a product-2.
      Parameters:
      ea - Equality across the first element of the product.
      eb - Equality across the second element of the product.
      Returns:
      An equal instance for a product-2.
    • p3Equal

      public static <A, B, C> Equal<P3<A,B,C>> p3Equal(Equal<A> ea, Equal<B> eb, Equal<C> ec)
      An equal instance for a product-3.
      Parameters:
      ea - Equality across the first element of the product.
      eb - Equality across the second element of the product.
      ec - Equality across the third element of the product.
      Returns:
      An equal instance for a product-3.
    • p4Equal

      public static <A, B, C, D> Equal<P4<A,B,C,D>> p4Equal(Equal<A> ea, Equal<B> eb, Equal<C> ec, Equal<D> ed)
      An equal instance for a product-4.
      Parameters:
      ea - Equality across the first element of the product.
      eb - Equality across the second element of the product.
      ec - Equality across the third element of the product.
      ed - Equality across the fourth element of the product.
      Returns:
      An equal instance for a product-4.
    • p5Equal

      public static <A, B, C, D, E> Equal<P5<A,B,C,D,E>> p5Equal(Equal<A> ea, Equal<B> eb, Equal<C> ec, Equal<D> ed, Equal<E> ee)
      An equal instance for a product-5.
      Parameters:
      ea - Equality across the first element of the product.
      eb - Equality across the second element of the product.
      ec - Equality across the third element of the product.
      ed - Equality across the fourth element of the product.
      ee - Equality across the fifth element of the product.
      Returns:
      An equal instance for a product-5.
    • p6Equal

      public static <A, B, C, D, E, F$> Equal<P6<A,B,C,D,E,F$>> p6Equal(Equal<A> ea, Equal<B> eb, Equal<C> ec, Equal<D> ed, Equal<E> ee, Equal<F$> ef)
      An equal instance for a product-6.
      Parameters:
      ea - Equality across the first element of the product.
      eb - Equality across the second element of the product.
      ec - Equality across the third element of the product.
      ed - Equality across the fourth element of the product.
      ee - Equality across the fifth element of the product.
      ef - Equality across the sixth element of the product.
      Returns:
      An equal instance for a product-6.
    • p7Equal

      public static <A, B, C, D, E, F$, G> Equal<P7<A,B,C,D,E,F$,G>> p7Equal(Equal<A> ea, Equal<B> eb, Equal<C> ec, Equal<D> ed, Equal<E> ee, Equal<F$> ef, Equal<G> eg)
      An equal instance for a product-7.
      Parameters:
      ea - Equality across the first element of the product.
      eb - Equality across the second element of the product.
      ec - Equality across the third element of the product.
      ed - Equality across the fourth element of the product.
      ee - Equality across the fifth element of the product.
      ef - Equality across the sixth element of the product.
      eg - Equality across the seventh element of the product.
      Returns:
      An equal instance for a product-7.
    • p8Equal

      public static <A, B, C, D, E, F$, G, H> Equal<P8<A,B,C,D,E,F$,G,H>> p8Equal(Equal<A> ea, Equal<B> eb, Equal<C> ec, Equal<D> ed, Equal<E> ee, Equal<F$> ef, Equal<G> eg, Equal<H> eh)
      An equal instance for a product-8.
      Parameters:
      ea - Equality across the first element of the product.
      eb - Equality across the second element of the product.
      ec - Equality across the third element of the product.
      ed - Equality across the fourth element of the product.
      ee - Equality across the fifth element of the product.
      ef - Equality across the sixth element of the product.
      eg - Equality across the seventh element of the product.
      eh - Equality across the eighth element of the product.
      Returns:
      An equal instance for a product-8.
    • v2Equal

      public static <A> Equal<V2<A>> v2Equal(Equal<A> ea)
      An equal instance for a vector-2.
      Parameters:
      ea - Equality across the elements of the vector.
      Returns:
      An equal instance for a vector-2.
    • v3Equal

      public static <A> Equal<V3<A>> v3Equal(Equal<A> ea)
      An equal instance for a vector-3.
      Parameters:
      ea - Equality across the elements of the vector.
      Returns:
      An equal instance for a vector-3.
    • v4Equal

      public static <A> Equal<V4<A>> v4Equal(Equal<A> ea)
      An equal instance for a vector-4.
      Parameters:
      ea - Equality across the elements of the vector.
      Returns:
      An equal instance for a vector-4.
    • v5Equal

      public static <A> Equal<V5<A>> v5Equal(Equal<A> ea)
      An equal instance for a vector-5.
      Parameters:
      ea - Equality across the elements of the vector.
      Returns:
      An equal instance for a vector-5.
    • v6Equal

      public static <A> Equal<V6<A>> v6Equal(Equal<A> ea)
      An equal instance for a vector-6.
      Parameters:
      ea - Equality across the elements of the vector.
      Returns:
      An equal instance for a vector-6.
    • v7Equal

      public static <A> Equal<V7<A>> v7Equal(Equal<A> ea)
      An equal instance for a vector-7.
      Parameters:
      ea - Equality across the elements of the vector.
      Returns:
      An equal instance for a vector-7.
    • v8Equal

      public static <A> Equal<V8<A>> v8Equal(Equal<A> ea)
      An equal instance for a vector-8.
      Parameters:
      ea - Equality across the elements of the vector.
      Returns:
      An equal instance for a vector-8.
    • hListEqual

      public static <E, L extends HList<L>> Equal<HList.HCons<E,L>> hListEqual(Equal<E> e, Equal<L> l)
      An equal instance for heterogeneous lists.
      Parameters:
      e - Equality for the first element of the list.
      l - Equality for the rest of the list.
      Returns:
      an equal instance for a heterogeneous list.
    • setEqual

      public static <A> Equal<Set<A>> setEqual(Equal<A> e)
      Equal instance for sets.
      Parameters:
      e - Equality for the set elements.
      Returns:
      An equal instance for sets.
    • treeMapEqual

      public static <K, V> Equal<TreeMap<K,V>> treeMapEqual(Equal<K> k, Equal<V> v)
    • writerEqual

      public static <A, B> Equal<Writer<A,B>> writerEqual(Equal<A> eq1, Equal<B> eq2)
    • equals0

      public static <A> boolean equals0(Class<? super A> clazz, A self, Object other, Equal<A> equal)
      Helper method to implement Object.equals(Object) correctly. DO NOT USE it for any other purpose.
      Parameters:
      clazz - the class in which the Object.equals(Object) is implemented
      self - a reference to 'this'
      other - the other object of the comparison
      equal - an equal instance for the type of self (that use anyEqual() if generic type).
      Returns:
      true if self and other are equal
    • equals0

      public static <A> boolean equals0(Class<? super A> clazz, A self, Object other, F0<Equal<A>> equal)
      Helper method to implement Object.equals(Object) correctly. DO NOT USE it for any other purpose.
      Parameters:
      clazz - the class in which the Object.equals(Object) is implemented
      self - a reference to 'this'
      other - the other object of the comparison
      equal - a lazy equal instance for the type (that use anyEqual() if generic type)..
      Returns:
      true if self and other are equal