Class BiFunctionSupport
- java.lang.Object
-
- net.shibboleth.utilities.java.support.logic.BiFunctionSupport
-
public final class BiFunctionSupport extends Object
Helper class for constructingBiFunctions in a Spring-friendly manner.- Since:
- 8.1.0
-
-
Constructor Summary
Constructors Modifier Constructor Description privateBiFunctionSupport()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods 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 ofBiFunction.andThen(Function).static <T,U,V>
BiFunction<T,U,V>constant(V target)Creates aBiFunctionthat returns a constant value.static <T,U>
BiFunction<T,U,Boolean>forBiPredicate(BiPredicate<? super T,? super U> predicate)Creates aBiFunctionthat returns the same boolean output as the givenBiPredicatefor all inputs.static <A,B,C>
BiFunction<A,B,C>forFunctionOfFirstArg(Function<? super A,? extends C> function)Adapts aFunctioninto a {BiFunction} that ignores the second argument.static <A,B,C>
BiFunction<A,B,C>forFunctionOfSecondArg(Function<? super B,? extends C> function)Adapts aFunctioninto a {BiFunction} that ignores the first argument.
-
-
-
Method Detail
-
constant
@Nonnull public static <T,U,V> BiFunction<T,U,V> constant(@Nonnull @ParameterName(name="target") V target)
Creates aBiFunctionthat returns a constant value.- Type Parameters:
T- type of object the function needs to act onU- type of object the function needs to act onV- 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 ofBiFunction.andThen(Function).- Type Parameters:
A- input to composedBiFunctionB- input to composedBiFunctionC- output of inputBiFunctionD- output of composedBiFunction- Parameters:
g- the second function to applyf- the firstBiFunctionto apply- Returns:
- the composition of
fandg - 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 aBiFunctionthat returns the same boolean output as the givenBiPredicatefor all inputs.- Type Parameters:
T- input typeU- input type- Parameters:
predicate- inputBiPredicate- 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 aFunctioninto a {BiFunction} that ignores the second argument.- Type Parameters:
A- input type of functionB- ignored argument typeC- 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 aFunctioninto a {BiFunction} that ignores the first argument.- Type Parameters:
A- ignored argument typeB- input type of functionC- return type- Parameters:
function- the function to apply- Returns:
- the adapted object
- Since:
- 8.3.0
-
-