Class BiPredicateSupport
- java.lang.Object
-
- net.shibboleth.utilities.java.support.logic.BiPredicateSupport
-
public final class BiPredicateSupport extends Object
Helper class for constructing BiPredicates in a Spring-friendly manner.- Since:
- 8.1.0
-
-
Constructor Summary
Constructors Modifier Constructor Description privateBiPredicateSupport()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,U>
BiPredicate<T,U>and(Iterable<? extends BiPredicate<? super T,? super U>> components)static <T,U>
BiPredicate<T,U>and(BiPredicate<? super T,? super U>... components)static <T,U>
BiPredicate<T,U>and(BiPredicate<T,U> first, BiPredicate<? super T,? super U> second)static <T,U>
BiPredicate<T,U>fromBiFunction(BiFunction<? super T,? super U,Boolean> function, BiPredicate<T,U> defValue)Creates aBiPredicatethat applies aBiFunctionto inputs and returns its result, or a default value if null.static <T,U>
BiPredicate<T,U>not(BiPredicate<? super T,? super U> predicate)static <T,U>
BiPredicate<T,U>or(Iterable<? extends BiPredicate<? super T,? super U>> components)static <T,U>
BiPredicate<T,U>or(BiPredicate<? super T,? super U>... components)static <T,U>
BiPredicate<T,U>or(BiPredicate<T,U> first, BiPredicate<? super T,? super U> second)
-
-
-
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 aBiPredicatethat applies aBiFunctionto inputs and returns its result, or a default value if null.- Type Parameters:
T- type of function inputU- type of function input- Parameters:
function- function to apply to inputsdefValue- default predicate to apply if function returns null- Returns:
- a
BiPredicateadapter
-
not
@Nonnull public static <T,U> BiPredicate<T,U> not(@Nonnull BiPredicate<? super T,? super U> predicate)
- Type Parameters:
T- predicate input typeU- 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 aBiPredicatethat evaluates totrueif each of its components evaluates totrue. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a falseBiPredicateis found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of thisBiPredicate. Ifcomponentsis empty, the returnedBiPredicatewill always evaluate totrue.- Type Parameters:
T- predicate input typeU- predicate input type- Parameters:
components- theBiPredicates 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 aBiPredicatethat evaluates totrueif each of its components evaluates totrue. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a falseBiPredicateis found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this predicate. Ifcomponentsis empty, the returnedBiPredicatewill always evaluate totrue.- Type Parameters:
T- predicate input typeU- predicate input type- Parameters:
components- theBiPredicates 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 aBiPredicatethat evaluates totrueif each of its components evaluates totrue. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a falseBiPredicateis found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of thisBiPredicate. Ifcomponentsis empty, the returnedBiPredicatewill always evaluate totrue.- Type Parameters:
T- predicate input typeU- predicate input type- Parameters:
first- the firstBiPredicatesecond- the secondBiPredicate- Returns:
- the composite
BiPredicate
-
or
@Nonnull public static <T,U> BiPredicate<T,U> or(@Nonnull Iterable<? extends BiPredicate<? super T,? super U>> components)
Returns aBiPredicatethat evaluates totrueif any one of its components evaluates totrue. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a trueBiPredicateis found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of thisBiPredicate. Ifcomponentsis empty, the returnedBiPredicatewill always evaluate tofalse.- Type Parameters:
T- predicate input typeU- predicate input type- Parameters:
components- theBiPredicates 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 aBiPredicatethat evaluates totrueif any one of its components evaluates totrue. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a trueBiPredicateis found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of thisBiPredicate. Ifcomponentsis empty, the returnedBiPredicatewill always evaluate tofalse.- Type Parameters:
T- predicate input typeU- predicate input type- Parameters:
components- theBiPredicates 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 aBiPredicatethat evaluates totrueif any one of its components evaluates totrue. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a trueBiPredicateis found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of thisBiPredicate. Ifcomponentsis empty, the returnedBiPredicatewill always evaluate tofalse.- Type Parameters:
T- predicate input typeU- predicate input type- Parameters:
first- the firstBiPredicatesecond- the secondBiPredicate- Returns:
- the composite predicate
-
-