Package net.shibboleth.shared.logic
Class BiPredicateSupport
java.lang.Object
net.shibboleth.shared.logic.BiPredicateSupport
Helper class for constructing BiPredicates in a Spring-friendly manner.
- Since:
- 8.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumPrivate enum to optimize the true/false objects. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,U> BiPredicate<T, U> Returns aBiPredicatethat always evaluates to false.static <T,U> BiPredicate<T, U> Returns aBiPredicatethat always evaluates to true.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)
-
Constructor Details
-
BiPredicateSupport
private BiPredicateSupport()Constructor.
-
-
Method Details
-
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
-
alwaysTrue
Returns aBiPredicatethat always evaluates to true.- Type Parameters:
T- first argument typeU- second argument type- Returns:
- the conforming BiPredicate
- Since:
- 9.1.0
-
alwaysFalse
Returns aBiPredicatethat always evaluates to false.- Type Parameters:
T- first argument typeU- second argument type- Returns:
- the conforming BiPredicate
- Since:
- 9.1.0
-
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
-