Class BiPredicateSupport


  • public final class BiPredicateSupport
    extends Object
    Helper class for constructing BiPredicates in a Spring-friendly manner.
    Since:
    8.1.0
    • Constructor Detail

      • BiPredicateSupport

        private BiPredicateSupport()
        Constructor.
    • Method Detail

      • fromBiFunction

        @Nonnull
        public static <T,​U> BiPredicate<T,​U> fromBiFunction​(@Nonnull
                                                                        BiFunction<? super T,​? super U,​Boolean> function,
                                                                        @Nonnull
                                                                        BiPredicate<T,​U> defValue)
        Creates a BiPredicate that applies a BiFunction to inputs and returns its result, or a default value if null.
        Type Parameters:
        T - type of function input
        U - type of function input
        Parameters:
        function - function to apply to inputs
        defValue - default predicate to apply if function returns null
        Returns:
        a BiPredicate adapter
      • not

        @Nonnull
        public static <T,​U> BiPredicate<T,​U> not​(@Nonnull
                                                             BiPredicate<? super T,​? super U> predicate)
        Returns a BiPredicate that evaluates to true if the given BiPredicate evaluates to false.
        Type Parameters:
        T - predicate input type
        U - predicate input type
        Parameters:
        predicate - the predicate to negate
        Returns:
        the negated BiPredicate
      • and

        @Nonnull
        public static <T,​U> BiPredicate<T,​U> and​(@Nonnull
                                                             Iterable<? extends BiPredicate<? super T,​? super U>> components)
        Returns a BiPredicate that evaluates to true if each of its components evaluates to true. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a false BiPredicate is found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this BiPredicate. If components is empty, the returned BiPredicate will always evaluate to true.
        Type Parameters:
        T - predicate input type
        U - predicate input type
        Parameters:
        components - the BiPredicates to combine
        Returns:
        the composite BiPredicate
      • and

        @SafeVarargs
        @Nonnull
        public static <T,​U> BiPredicate<T,​U> and​(@Nonnull
                                                             BiPredicate<? super T,​? super U>... components)
        Returns a BiPredicate that evaluates to true if each of its components evaluates to true. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a false BiPredicate is found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this predicate. If components is empty, the returned BiPredicate will always evaluate to true.
        Type Parameters:
        T - predicate input type
        U - predicate input type
        Parameters:
        components - the BiPredicates to combine
        Returns:
        the composite BiPredicate
      • and

        @Nonnull
        public static <T,​U> BiPredicate<T,​U> and​(@Nonnull
                                                             BiPredicate<T,​U> first,
                                                             @Nonnull
                                                             BiPredicate<? super T,​? super U> second)
        Returns a BiPredicate that evaluates to true if each of its components evaluates to true. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a false BiPredicate is found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this BiPredicate. If components is empty, the returned BiPredicate will always evaluate to true.
        Type Parameters:
        T - predicate input type
        U - predicate input type
        Parameters:
        first - the first BiPredicate
        second - the second BiPredicate
        Returns:
        the composite BiPredicate
      • or

        @Nonnull
        public static <T,​U> BiPredicate<T,​U> or​(@Nonnull
                                                            Iterable<? extends BiPredicate<? super T,​? super U>> components)
        Returns a BiPredicate that evaluates to true if any one of its components evaluates to true. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a true BiPredicate is found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this BiPredicate. If components is empty, the returned BiPredicate will always evaluate to false.
        Type Parameters:
        T - predicate input type
        U - predicate input type
        Parameters:
        components - the BiPredicates to combine
        Returns:
        the composite BiPredicate
      • or

        @SafeVarargs
        @Nonnull
        public static <T,​U> BiPredicate<T,​U> or​(@Nonnull
                                                            BiPredicate<? super T,​? super U>... components)
        Returns a BiPredicate that evaluates to true if any one of its components evaluates to true. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a true BiPredicate is found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this BiPredicate. If components is empty, the returned BiPredicate will always evaluate to false.
        Type Parameters:
        T - predicate input type
        U - predicate input type
        Parameters:
        components - the BiPredicates to combine
        Returns:
        the composite BiPredicate
      • or

        @Nonnull
        public static <T,​U> BiPredicate<T,​U> or​(@Nonnull
                                                            BiPredicate<T,​U> first,
                                                            @Nonnull
                                                            BiPredicate<? super T,​? super U> second)
        Returns a BiPredicate that evaluates to true if any one of its components evaluates to true. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a true BiPredicate is found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this BiPredicate. If components is empty, the returned BiPredicate will always evaluate to false.
        Type Parameters:
        T - predicate input type
        U - predicate input type
        Parameters:
        first - the first BiPredicate
        second - the second BiPredicate
        Returns:
        the composite predicate