Package net.shibboleth.shared.logic

# Class BiFunctionSupport

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

public final class BiFunctionSupport extends Object
Helper class for constructing `BiFunction`s in a Spring-friendly manner.

Since:
  8.1.0

## Constructor Summary

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

## Method Summary

Modifier and Type
Method
Description
`static <A, B, C, D> BiFunction<A,B,D>`
`compose(Function<? super C,? extends D> g, BiFunction<A,B,? extends C> f)`
A static version of `BiFunction.andThen(Function)`.
`static <T, U, V> BiFunction<T,U,V>`
`constant(V target)`
Creates a `BiFunction` that returns a constant value.
`static <T, U> BiFunction<T,U,Boolean>`
`forBiPredicate(BiPredicate<? super T,? super U> predicate)`
Creates a `BiFunction` that returns the same boolean output as the given `BiPredicate` for all inputs.
`static <A, B, C> BiFunction<A,B,C>`
`forFunctionOfFirstArg(Function<? super A,? extends C> function)`
Adapts a `Function` into a {BiFunction} that ignores the second argument.
`static <A, B, C> BiFunction<A,B,C>`
`forFunctionOfSecondArg(Function<? super B,? extends C> function)`
Adapts a `Function` into a {BiFunction} that ignores the first argument.

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

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

## Constructor Details

### BiFunctionSupport

private BiFunctionSupport()
Constructor.

## Method Details

### constant

@Nonnull public static <T, U, V> BiFunction<T,U,V> constant(@Nonnull @ParameterName(name="target") V target)
Creates a `BiFunction` that returns a constant value.

Type Parameters:
  `T` - type of object the function needs to act on
  `U` - type of object the function needs to act on
  `V` - type of object being returned
Parameters:
  `target` - the value to return from the function
Returns:
  the constructed function

### compose

@Nonnull public static <A, B, C, D> BiFunction<A,B,D> compose(@Nonnull @ParameterName(name="g") Function<? super C,? extends D> g, @Nonnull @ParameterName(name="f") BiFunction<A,B,? extends C> f)
A static version of `BiFunction.andThen(Function)`.

Type Parameters:
  `A` - input to composed `BiFunction`
  `B` - input to composed `BiFunction`
  `C` - output of input `BiFunction`
  `D` - output of composed `BiFunction`
Parameters:
  `g` - the second function to apply
  `f` - the first `BiFunction` to apply
Returns:
  the composition of `f` and `g`
See Also:
  - function composition

### forBiPredicate

@Nonnull public static <T, U> BiFunction<T,U,Boolean> forBiPredicate(@Nonnull @ParameterName(name="predicate") BiPredicate<? super T,? super U> predicate)
Creates a `BiFunction` that returns the same boolean output as the given `BiPredicate` for all inputs.

Type Parameters:
  `T` - input type
  `U` - input type
Parameters:
  `predicate` - input `BiPredicate`
Returns:
  a corresponding `BiFunction`

### forFunctionOfFirstArg

@Nonnull public static <A, B, C> BiFunction<A,B,C> forFunctionOfFirstArg(@Nonnull @ParameterName(name="function") Function<? super A,? extends C> function)
Adapts a `Function` into a {BiFunction} that ignores the second argument.

Type Parameters:
  `A` - input type of function
  `B` - ignored argument type
  `C` - return type
Parameters:
  `function` - the function to apply
Returns:
  the adapted object
Since:
  8.3.0

### forFunctionOfSecondArg

@Nonnull public static <A, B, C> BiFunction<A,B,C> forFunctionOfSecondArg(@Nonnull @ParameterName(name="function") Function<? super B,? extends C> function)
Adapts a `Function` into a {BiFunction} that ignores the first argument.

Type Parameters:
  `A` - ignored argument type
  `B` - input type of function
  `C` - return type
Parameters:
  `function` - the function to apply
Returns:
  the adapted object
Since:
  8.3.0