Class Functions
java.lang.Object
org.wildfly.clustering.cache.function.Functions
Reusable function implementations.
- Author:
- Paul Ferraro
-
Method Summary
Modifier and TypeMethodDescriptionstatic <R> DoubleFunction<R>
constantDoubleFunction
(R result) Returns a function that always returns a constant result, regardless of input.static <T,
R> Function<T, R> constantFunction
(R result) Returns a function that always returns a constant result, regardless of input.static <R> IntFunction<R>
constantIntFunction
(R result) Returns a function that always returns a constant result, regardless of input.static <R> LongFunction<R>
constantLongFunction
(R result) Returns a function that always returns a constant result, regardless of input.static <R> UnaryOperator<R>
constantOperator
(R result) Returns an operator that always returns a constant result, regardless of input.static <T,
R> Function<T, R> Returns a function that always returns null, regardless of input.static <R> UnaryOperator<R>
Returns an operator that always returns null, regardless of input.quiet
(org.wildfly.common.function.ExceptionFunction<T, R, E> function, BiFunction<T, Exception, RuntimeException> exceptionWrapper) Converts an ExceptionFunction to a Function, applying the specified exception wrapper on failure.static <T> UnaryOperator<T>
whenNullFunction
(Supplier<T> factory) Returns a function that replaces a null with the value provided by the specified factory.static <T> UnaryOperator<T>
whenNullFunction
(T replacement) Returns a function that replaces a null with the specified value.
-
Method Details
-
whenNullFunction
Returns a function that replaces a null with the specified value.- Type Parameters:
T
- the function type- Parameters:
replacement
- the value- Returns:
- a function that replaces a null with the specified value.
-
whenNullFunction
Returns a function that replaces a null with the value provided by the specified factory.- Type Parameters:
T
- the function type- Parameters:
factory
- the provider of the replacement value- Returns:
- a function that replaces a null with the value provided by the specified factory.
-
nullOperator
Returns an operator that always returns null, regardless of input.- Type Parameters:
R
- the operator type- Returns:
- an operator that always returns null.
-
constantOperator
Returns an operator that always returns a constant result, regardless of input.- Type Parameters:
R
- the operator type- Parameters:
result
- the value returned by the constant operator- Returns:
- an operator that always returns the specified result
-
nullFunction
Returns a function that always returns null, regardless of input.- Type Parameters:
T
- the function parameter typeR
- the function return type- Returns:
- a function that always returns null.
-
constantFunction
Returns a function that always returns a constant result, regardless of input.- Type Parameters:
T
- the function parameter typeR
- the function return type- Parameters:
result
- the value to return by the constant function- Returns:
- a function that always returns the specified result
-
constantIntFunction
Returns a function that always returns a constant result, regardless of input.- Type Parameters:
R
- the function return type- Parameters:
result
- the value to return by the constant function- Returns:
- a function that always returns the specified result
-
constantLongFunction
Returns a function that always returns a constant result, regardless of input.- Type Parameters:
R
- the function return type- Parameters:
result
- the value to return by the constant function- Returns:
- a function that always returns the specified result
-
constantDoubleFunction
Returns a function that always returns a constant result, regardless of input.- Type Parameters:
R
- the function return type- Parameters:
result
- the value to return by the constant function- Returns:
- a function that always returns the specified result
-
quiet
public static <T,R, Function<T,E extends Exception> R> quiet(org.wildfly.common.function.ExceptionFunction<T, R, E> function, BiFunction<T, Exception, RuntimeException> exceptionWrapper) Converts an ExceptionFunction to a Function, applying the specified exception wrapper on failure.- Type Parameters:
T
- the function parameter typeR
- the function return typeE
- the function exception type- Parameters:
function
- the exception function to quietexceptionWrapper
- an exception wrapper- Returns:
- a function.
-