Class BiPredicates

java.lang.Object
eu.bandm.tools.util.java.BiPredicates

public abstract class BiPredicates extends Object
Library of constants and operations for working with binary predicates.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static <A, B> BiPredicate<A,B>
    all()
    Returns a binary predicate that is true for all arguments.
    static <A, B> BiPredicate<A,B>
    complement(BiPredicate<? super A,? super B> pred)
    Returns a binary predicate that is true for all arguments where the given predicate is false and vice versa.
    static <A, B> BiPredicate<Collection<? extends A>,Collection<? extends B>>
    cover(BiPredicate<A,B> rel)
    Returns a binary predicate that is true for two collections if and only if for every element on either side there is an element on the other side such that the given binary predicate is true.
    static <A, B> BiPredicate<A,B>
    eq()
    Returns a binary predicate that is true if and only if the arguments are identical.
    static <A extends Comparable<? super A>>
    BiPredicate<A,A>
    Returns a binary predicate that is true if and only if the first argument is equal to the second, according to the natural order.
    static <A> BiPredicate<A,A>
    equal(Comparator<? super A> order)
    Returns a binary predicate that is true if and only if the first argument is equal to the second, according to the given order.
    static <A, B> BiPredicate<A,B>
    Deprecated.
    use Object::equals instead
    static <A extends Comparable<? super A>>
    BiPredicate<A,A>
    Returns a binary predicate that is true if and only if the first argument is greater than the second, according to the natural order.
    static <A> BiPredicate<A,A>
    greater(Comparator<? super A> order)
    Returns a binary predicate that is true if and only if the first argument is greater than the second, according to the given order.
    static <A extends Comparable<? super A>>
    BiPredicate<A,A>
    Returns a binary predicate that is true if and only if the first argument is greater than or equal to the second, according to the natural order.
    static <A> BiPredicate<A,A>
    greaterOrEqual(Comparator<? super A> order)
    Returns a binary predicate that is true if and only if the first argument is greater than or equal to the second, according to the given order.
    static <A, B> BiPredicate<A,B>
    intersection(Collection<? extends BiPredicate<? super A,? super B>> rels)
    Returns a predicate that is true for all arguments where all of the given predicates are.
    static <A, B> BiPredicate<B,A>
    inverse(BiPredicate<? super A,? super B> pred)
    Returns a binary predicate that is true for all arguments where the given predicate is for the flipped pair of arguments.
    static <A, B> BiPredicate<A,A>
    kernel(Function<? super A,? extends B> fun, BiPredicate<? super B,? super B> pred)
    Returns a binary predicate that is true if and only if the given binary predicate is true for the results of the given function.
    static <A, B, C, D>
    BiPredicate<A,C>
    kernel(Function<? super A,? extends B> left, Function<? super C,? extends D> right, BiPredicate<? super B,? super D> pred)
    Returns a binary predicate that is true if and only if the given binary predicate is true for the results of the two given functions.
    static <A extends Comparable<? super A>>
    BiPredicate<A,A>
    Returns a binary predicate that is true if and only if the first argument is less than the second, according to the natural order.
    static <A> BiPredicate<A,A>
    less(Comparator<? super A> order)
    Returns a binary predicate that is true if and only if the first argument is less than the second, according to the given order.
    static <A extends Comparable<? super A>>
    BiPredicate<A,A>
    Returns a binary predicate that is true if and only if the first argument is less than or equal to the second, according to the natural order.
    static <A> BiPredicate<A,A>
    lessOrEqual(Comparator<? super A> order)
    Returns a binary predicate that is true if and only if the first argument is less than or equal to the second, according to the given order.
    static <A, B> BiPredicate<A,B>
    Returns a binary predicate that is false for all arguments.
    static <A, B> BiPredicate<A,B>
    union(Collection<? extends BiPredicate<? super A,? super B>> rels)
    Returns a predicate that is true for all arguments where any of the given predicates is.

    Methods inherited from class java.lang.Object

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

    • all

      public static <A, B> BiPredicate<A,B> all()
      Returns a binary predicate that is true for all arguments.
      Type Parameters:
      A - the first argument type
      B - the second argument type
      Returns:
      a binary predicate that is true for all arguments, including null
    • none

      public static <A, B> BiPredicate<A,B> none()
      Returns a binary predicate that is false for all arguments.
      Type Parameters:
      A - the first argument type
      B - the second argument type
      Returns:
      a binary predicate that is false for all arguments, including null
    • eq

      public static <A, B> BiPredicate<A,B> eq()
      Returns a binary predicate that is true if and only if the arguments are identical.
      Type Parameters:
      A - the first argument type
      B - the second argument type
      Returns:
      a binary predicate that true if and only if the arguments are identical according to ==
    • equals

      @Deprecated(forRemoval=false, since="1.0") public static <A, B> BiPredicate<A,B> equals()
      Deprecated.
      use Object::equals instead
      Returns a binary predicate that is true if and only if the arguments are equal.
      Type Parameters:
      A - the first argument type
      B - the second argument type
      Returns:
      a binary predicate that true if and only if the arguments are equal according to Objects.equals(Object, Object)
    • lessOrEqual

      public static <A> BiPredicate<A,A> lessOrEqual(Comparator<? super A> order)
      Returns a binary predicate that is true if and only if the first argument is less than or equal to the second, according to the given order.
      Type Parameters:
      A - the argument type
      Parameters:
      order - a comparator that specifies the desired order
      Returns:
      a binary predicate that true if and only if the first argument is less than or equal to the second according to Comparator.compare(T, T)
      Throws:
      NullPointerException - if order is null
    • lessOrEqual

      public static <A extends Comparable<? super A>> BiPredicate<A,A> lessOrEqual()
      Returns a binary predicate that is true if and only if the first argument is less than or equal to the second, according to the natural order.
      Type Parameters:
      A - the argument type
      Returns:
      a binary predicate that true if and only if the first argument is less than or equal to the second according to Comparable.compareTo(T)
    • less

      public static <A> BiPredicate<A,A> less(Comparator<? super A> order)
      Returns a binary predicate that is true if and only if the first argument is less than the second, according to the given order.
      Type Parameters:
      A - the argument type
      Parameters:
      order - a comparator that specifies the desired order
      Returns:
      a binary predicate that true if and only if the first argument is less than the second according to Comparator.compare(T, T)
      Throws:
      NullPointerException - if order is null
    • less

      public static <A extends Comparable<? super A>> BiPredicate<A,A> less()
      Returns a binary predicate that is true if and only if the first argument is less than the second, according to the natural order.
      Type Parameters:
      A - the argument type
      Returns:
      a binary predicate that true if and only if the first argument is less than the second according to Comparable.compareTo(T)
    • equal

      public static <A extends Comparable<? super A>> BiPredicate<A,A> equal()
      Returns a binary predicate that is true if and only if the first argument is equal to the second, according to the natural order.
      Type Parameters:
      A - the argument type
      Returns:
      a binary predicate that true if and only if the first argument is equal to the second according to Comparable.compareTo(T)
    • greater

      public static <A extends Comparable<? super A>> BiPredicate<A,A> greater()
      Returns a binary predicate that is true if and only if the first argument is greater than the second, according to the natural order.
      Type Parameters:
      A - the argument type
      Returns:
      a binary predicate that true if and only if the first argument is greater than the second according to Comparable.compareTo(T)
    • greaterOrEqual

      public static <A extends Comparable<? super A>> BiPredicate<A,A> greaterOrEqual()
      Returns a binary predicate that is true if and only if the first argument is greater than or equal to the second, according to the natural order.
      Type Parameters:
      A - the argument type
      Returns:
      a binary predicate that true if and only if the first argument is greater than or equal to the second according to Comparable.compareTo(T)
    • greaterOrEqual

      public static <A> BiPredicate<A,A> greaterOrEqual(Comparator<? super A> order)
      Returns a binary predicate that is true if and only if the first argument is greater than or equal to the second, according to the given order.
      Type Parameters:
      A - the argument type
      Parameters:
      order - a comparator that specifies the desired order
      Returns:
      a binary predicate that true if and only if the first argument is greater than or equal to the second according to Comparator.compare(T, T)
      Throws:
      NullPointerException - if order is null
    • greater

      public static <A> BiPredicate<A,A> greater(Comparator<? super A> order)
      Returns a binary predicate that is true if and only if the first argument is greater than the second, according to the given order.
      Type Parameters:
      A - the argument type
      Parameters:
      order - a comparator that specifies the desired order
      Returns:
      a binary predicate that true if and only if the first argument is greater than the second according to Comparator.compare(T, T)
      Throws:
      NullPointerException - if order is null
    • equal

      public static <A> BiPredicate<A,A> equal(Comparator<? super A> order)
      Returns a binary predicate that is true if and only if the first argument is equal to the second, according to the given order.
      Type Parameters:
      A - the argument type
      Parameters:
      order - a comparator that specifies the desired order
      Returns:
      a binary predicate that true if and only if the first argument is equal to the second according to Comparator.compare(T, T)
      Throws:
      NullPointerException - if order is null
    • inverse

      public static <A, B> BiPredicate<B,A> inverse(BiPredicate<? super A,? super B> pred)
      Returns a binary predicate that is true for all arguments where the given predicate is for the flipped pair of arguments.
      Type Parameters:
      A - the first argument type
      B - the second argument type
      Parameters:
      pred - a binary predicate
      Returns:
      a binary predicate that is true for (a, b) if and only if pred is true for (b, a)
      Throws:
      NullPointerException - if pred is null
    • complement

      public static <A, B> BiPredicate<A,B> complement(BiPredicate<? super A,? super B> pred)
      Returns a binary predicate that is true for all arguments where the given predicate is false and vice versa.
      Type Parameters:
      A - the first argument type
      B - the second argument type
      Parameters:
      pred - a binary predicate
      Returns:
      a binary predicate that is true for all arguments where pred is false and vice versa
      Throws:
      NullPointerException - if pred is null
    • kernel

      public static <A, B, C, D> BiPredicate<A,C> kernel(Function<? super A,? extends B> left, Function<? super C,? extends D> right, BiPredicate<? super B,? super D> pred)
      Returns a binary predicate that is true if and only if the given binary predicate is true for the results of the two given functions.
      Type Parameters:
      A - the first argument type of the resulting predicate
      B - the second argument type of the resulting predicate
      C - the first argument type of the given predicate
      D - the second argument type of the given predicate
      Parameters:
      left - the function used to transform the first argument
      right - the function used to transform the second argument
      pred - the binary predicate to apply to the results
      Returns:
      a binary predicate that is true for (a, b) if and only if pred is true for (left(a), right(b))
      Throws:
      NullPointerException - if any of left, right, pred is null
    • kernel

      public static <A, B> BiPredicate<A,A> kernel(Function<? super A,? extends B> fun, BiPredicate<? super B,? super B> pred)
      Returns a binary predicate that is true if and only if the given binary predicate is true for the results of the given function.
      Type Parameters:
      A - the argument type of the resulting predicate
      B - the argument type of the given predicate
      Parameters:
      fun - the function used to transform the arguments
      pred - the binary predicate to apply to the results
      Returns:
      a binary predicate that is true for (a, b) if and only if pred is true for (fun(a), fun(b))
      Throws:
      NullPointerException - if any of fun, pred is null
    • cover

      public static <A, B> BiPredicate<Collection<? extends A>,Collection<? extends B>> cover(BiPredicate<A,B> rel)
      Returns a binary predicate that is true for two collections if and only if for every element on either side there is an element on the other side such that the given binary predicate is true.
      Type Parameters:
      A - the first argument type of the given predicate
      B - the second argument type of the given predicate
      Parameters:
      rel - the given binary predicate
      Returns:
      a binary predicate that holds for (as, bs) if and only if for every element a in as there is an element b in bs such that rel is true for (a, b), and vice versa
      Throws:
      NullPointerException - if rel is null
    • union

      public static <A, B> BiPredicate<A,B> union(Collection<? extends BiPredicate<? super A,? super B>> rels)
      Returns a predicate that is true for all arguments where any of the given predicates is.
      Type Parameters:
      A - the first argument type
      B - the second argument type
      Parameters:
      rels - a collection of binary predicates
      Returns:
      a predicate that is true for (a, b) if and only if there is a binary predicate r in rels for which this is the case
      Throws:
      NullPointerException - if rels or any element of it is null
    • intersection

      public static <A, B> BiPredicate<A,B> intersection(Collection<? extends BiPredicate<? super A,? super B>> rels)
      Returns a predicate that is true for all arguments where all of the given predicates are.
      Type Parameters:
      A - the first argument type
      B - the second argument type
      Parameters:
      rels - a collection of binary predicates
      Returns:
      a predicate that is true for (a, b) if and only if this is the case for all binary predicates r in rels
      Throws:
      NullPointerException - if rels or any element of it is null