Package net.shibboleth.shared.logic

# Class BiPredicateSupport

java.lang.Object
net.shibboleth.shared.logic.BiPredicateSupport

public final class BiPredicateSupport extends Object
Helper class for constructing BiPredicates in a Spring-friendly manner.

Since:
  8.1.0

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`(package private) static enum`
`BiPredicateSupport.ObjectBiPredicate`
Private enum to optimize the true/false objects.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`BiPredicateSupport()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static <T, U> BiPredicate<T,U>`
`alwaysFalse()`
Returns a `BiPredicate` that always evaluates to false.
`static <T, U> BiPredicate<T,U>`
`alwaysTrue()`
Returns a `BiPredicate` that always evaluates to true.
`static <T, U> BiPredicate<T,U>`
`and(Iterable<? extends BiPredicate<? super T,? super U>> components)`
Returns a `BiPredicate` that evaluates to `true` if each of its components evaluates to `true`.
`static <T, U> BiPredicate<T,U>`
`and(BiPredicate<? super T,? super U>... components)`
Returns a `BiPredicate` that evaluates to `true` if each of its components evaluates to `true`.
`static <T, U> BiPredicate<T,U>`
`and(BiPredicate<T,U> first, BiPredicate<? super T,? super U> second)`
Returns a `BiPredicate` that evaluates to `true` if each of its components evaluates to `true`.
`static <T, U> BiPredicate<T,U>`
`fromBiFunction(BiFunction<? super T,? super U,Boolean> function, BiPredicate<T,U> defValue)`
Creates a `BiPredicate` that applies a `BiFunction` to inputs and returns its result, or a default value if null.
`static <T, U> BiPredicate<T,U>`
`not(BiPredicate<? super T,? super U> predicate)`
Returns a `BiPredicate` that evaluates to `true` if the given `BiPredicate` evaluates to `false`.
`static <T, U> BiPredicate<T,U>`
`or(Iterable<? extends BiPredicate<? super T,? super U>> components)`
Returns a `BiPredicate` that evaluates to `true` if any one of its components evaluates to `true`.
`static <T, U> BiPredicate<T,U>`
`or(BiPredicate<? super T,? super U>... components)`
Returns a `BiPredicate` that evaluates to `true` if any one of its components evaluates to `true`.
`static <T, U> BiPredicate<T,U>`
`or(BiPredicate<T,U> first, BiPredicate<? super T,? super U> second)`
Returns a `BiPredicate` that evaluates to `true` if any one of its components evaluates to `true`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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 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

### alwaysTrue

@Nonnull public static <T, U> BiPredicate<T,U> alwaysTrue()
Returns a `BiPredicate` that always evaluates to true.

Type Parameters:
  `T` - first argument type
  `U` - second argument type
Returns:
  the conforming BiPredicate
Since:
  9.1.0

### alwaysFalse

@Nonnull public static <T, U> BiPredicate<T,U> alwaysFalse()
Returns a `BiPredicate` that always evaluates to false.

Type Parameters:
  `T` - first argument type
  `U` - 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)
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 `BiPredicate`s 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 `BiPredicate`s 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 `BiPredicate`s 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 `BiPredicate`s 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