Class BinaryPredicates


  • public final class BinaryPredicates
    extends java.lang.Object
    Provides utility methods for binary predicates
    • Method Detail

      • not

        public static <T> BinaryPredicate<T> not​(BinaryPredicate<T> original)
        Negates the given binary predicate. Thus, the BinaryPredicate.test(Object, Object) will return the logically negated value of the original. For example, if the predicate is '<=', then this method will transform the predicate (a <= b) to !(a <= b), which is equivalent to (a > b).
        Parameters:
        original - the original predicate.
        Returns:
      • invert

        public static <T> BinaryPredicate<T> invert​(BinaryPredicate<T> original)
        Inverts the given binary predicate. Thus, if e.g. the predicate is '<=', then this method will transform the predicate (a <= b) to (a >= b).
        Parameters:
        original - the original predicate.
        Returns:
        the inverted predicate.
      • and

        public static <T> BinaryPredicate<T> and​(BinaryPredicate<T> leftPredicate,
                                                 BinaryPredicate<T> rightPredicate)
        Returns a logical 'and' combination of the two binary predicates. Thus, the resulting predicate will only be fulfilled as soon as both predicate test methods return true.
        Parameters:
        leftPredicate - the first predicate which shall be part of the and condition
        rightPredicate - the second predicate which shall be part of the and condition
        Returns:
        a predicate which represents a logical 'AND' between the two predicates