Top Description Inners Fields Constructors Methods
io.smallrye.common.function

public final Class Functions

extends Object
Class Inheritance
Imports
java.util.function.BiConsumer, .BiFunction, .BiPredicate, .Consumer, .DoubleFunction, .Function, .IntFunction, .LongFunction, .ObjDoubleConsumer, .ObjIntConsumer, .ObjLongConsumer, .Predicate, .Supplier, .ToDoubleBiFunction, .ToDoubleFunction, .ToIntBiFunction, .ToIntFunction, .ToLongBiFunction, .ToLongFunction, io.smallrye.common.constraint.Assert

A set of utility methods which return common functions.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final Consumer<AutoCloseable>
private static final Consumer<Exception>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
the first parameter type
T
,
the second parameter type
U
>
Runnable

Returns:

the capturing runnable
capturingRunnable
(BiConsumer<T, U>
the consumer to run (must not be null)
consumer
,
T
the first parameter to pass
param1
,
U
the second parameter to pass
param2
)

Get a runnable which executes the given consumer with captured values.

public static <
the parameter type
T
>
Runnable

Returns:

the capturing runnable
capturingRunnable
(Consumer<T>
the consumer to run (must not be null)
consumer
,
T
the parameter to pass
param
)

Get a runnable which executes the given consumer with captured values.

public static <
the parameter type
T
,
the restricted parameter type
TT extends T
>
Consumer<TT>

Returns:

a functionally equivalent consumer
cast
(Consumer<T>
a consumer
consumer
)

Returns a Consumer with identical behavior to the specified Consumer but with restricted parameter type.

public static <
the parameter type
T
,
the restricted parameter type
TT extends T
>
Predicate<TT>

Returns:

a functionally equivalent predicate
cast
(Predicate<T>
a predicate
predicate
)

Returns a Predicate with identical behavior to the specified Predicate but with restricted parameter type.

public static <
the return type
T extends TT
,
the relaxed return type
TT
>
Supplier<TT>

Returns:

a functionally equivalent supplier
cast
(Supplier<T>
a supplier
supplier
)

Returns a Supplier with identical behavior to the specified Supplier but with relaxed return type.

public static <
the parameter type
T
,
the return type
R extends RR
,
the restricted parameter type
TT extends T
,
the relaxed return type
RR
>
Function<TT, RR>

Returns:

a functionally equivalent function
cast
(Function<T, R>
a function
function
)

Returns a Function with identical behavior to the specified Function but with restricted parameter type and relaxed return type.

public static <
the return type
R extends RR
,
the relaxed return type
RR
>
DoubleFunction<RR>

Returns:

a functionally equivalent function
cast
(DoubleFunction<R>
a function
function
)

Returns a DoubleFunction with identical behavior to the specified DoubleFunction but with relaxed return type.

public static <
the return type
R extends RR
,
the relaxed return type
RR
>
IntFunction<RR>

Returns:

a functionally equivalent function
cast
(IntFunction<R>
a function
function
)

Returns a IntFunction with identical behavior to the specified IntFunction but with relaxed return type.

public static <
the return type
R extends RR
,
the relaxed return type
RR
>
LongFunction<RR>

Returns:

a functionally equivalent function
cast
(LongFunction<R>
a function
function
)

Returns a LongFunction with identical behavior to the specified LongFunction but with relaxed return type.

public static <
the parameter type
T
,
the restricted parameter type
TT extends T
>
ToDoubleFunction<TT>

Returns:

a functionally equivalent function
cast
(ToDoubleFunction<T>
a function
function
)

Returns a ToDoubleFunction with identical behavior to the specified ToDoubleFunction but with restricted parameter type.

public static <
the parameter type
T
,
the restricted parameter type
TT extends T
>
ToIntFunction<TT>

Returns:

a functionally equivalent function
cast
(ToIntFunction<T>
a function
function
)

Returns a ToIntFunction with identical behavior to the specified ToIntFunction but with restricted parameter type.

public static <
the parameter type
T
,
the restricted parameter type
TT extends T
>
ToLongFunction<TT>

Returns:

a functionally equivalent function
cast
(ToLongFunction<T>
a function
function
)

Returns a ToLongFunction with identical behavior to the specified ToLongFunction but with restricted parameter type.

public static <
the first parameter type
T
,
the second parameter type
U
,
the restricted first parameter type
TT extends T
,
the restricted second parameter type
UU extends U
>
BiConsumer<TT, UU>

Returns:

a functionally equivalent consumer
cast
(BiConsumer<T, U>
a consumer
consumer
)

Returns a BiConsumer with identical behavior to the specified BiConsumer but with restricted parameter types.

public static <
the parameter type
T
,
the restricted parameter type
TT extends T
>
ObjDoubleConsumer<TT>

Returns:

a functionally equivalent consumer
cast
(ObjDoubleConsumer<T>
a consumer
consumer
)

Returns a ObjDoubleConsumer with identical behavior to the specified ObjDoubleConsumer but with restricted parameter type.

public static <
the parameter type
T
,
the restricted parameter type
TT extends T
>
ObjIntConsumer<TT>

Returns:

a functionally equivalent consumer
cast
(ObjIntConsumer<T>
a consumer
consumer
)

Returns a ObjIntConsumer with identical behavior to the specified ObjIntConsumer but with restricted parameter type.

public static <
the parameter type
T
,
the restricted parameter type
TT extends T
>
ObjLongConsumer<TT>

Returns:

a functionally equivalent consumer
cast
(ObjLongConsumer<T>
a consumer
consumer
)

Returns a ObjLongConsumer with identical behavior to the specified ObjLongConsumer but with restricted parameter type.

public static <
the first parameter type
T
,
the second parameter type
U
,
the restricted first parameter type
TT extends T
,
the restricted second parameter type
UU extends U
>
BiPredicate<TT, UU>

Returns:

a functionally equivalent predicate
cast
(BiPredicate<T, U>
a predicate
predicate
)

Returns a BiPredicate with identical behavior to the specified BiPredicate but with restricted parameter types.

public static <
the first parameter type
T
,
the second parameter type
U
,
the return type
R extends RR
,
the restricted first parameter type
TT extends T
,
the restricted second parameter type
UU extends U
,
the relaxed return type
RR
>
BiFunction<TT, UU, RR>

Returns:

a functionally equivalent function
cast
(BiFunction<T, U, R>
a function
function
)

Returns a BiFunction with identical behavior to the specified BiFunction but with restricted parameter types and relaxed return type.

public static <
the first parameter type
T
,
the second parameter type
U
,
the restricted first parameter type
TT extends T
,
the restricted second parameter type
UU extends U
>
ToDoubleBiFunction<TT, UU>

Returns:

a functionally equivalent function
cast
(ToDoubleBiFunction<T, U>
a function
function
)

Returns a ToDoubleBiFunction with identical behavior to the specified ToDoubleBiFunction but with restricted parameter types.

public static <
the first parameter type
T
,
the second parameter type
U
,
the restricted first parameter type
TT extends T
,
the restricted second parameter type
UU extends U
>
ToIntBiFunction<TT, UU>

Returns:

a functionally equivalent function
cast
(ToIntBiFunction<T, U>
a function
function
)

Returns a ToIntBiFunction with identical behavior to the specified ToIntBiFunction but with restricted parameter types.

public static <
the first parameter type
T
,
the second parameter type
U
,
the restricted first parameter type
TT extends T
,
the restricted second parameter type
UU extends U
>
ToLongBiFunction<TT, UU>

Returns:

a functionally equivalent function
cast
(ToLongBiFunction<T, U>
a function
function
)

Returns a ToLongBiFunction with identical behavior to the specified ToLongBiFunction but with restricted parameter types.

public static <
the parameter type
T
,
the exception type
E extends EE
,
the restricted parameter type
TT extends T
,
the relaxed exception type
EE extends Exception
>
ExceptionConsumer<TT, EE>

Returns:

a functionally equivalent consumer
cast
(ExceptionConsumer<T, E>
a consumer
consumer
)

Returns a ExceptionConsumer with identical behavior to the specified ExceptionConsumer but with restricted parameter type and relaxed exception type.

public static <
the parameter type
T
,
the exception type
E extends EE
,
the restricted parameter type
TT extends T
,
the relaxed exception type
EE extends Exception
>
ExceptionPredicate<TT, EE>

Returns:

a functionally equivalent predicate
cast
(ExceptionPredicate<T, E>
a consumer
consumer
)

Returns a ExceptionPredicate with identical behavior to the specified ExceptionPredicate but with restricted parameter type and relaxed exception type.

public static <
the return type
T extends TT
,
the exception type
E extends EE
,
the relaxed return type
TT
,
the relaxed exception type
EE extends Exception
>
ExceptionSupplier<TT, EE>

Returns:

a functionally equivalent supplier
cast
(ExceptionSupplier<T, E>
a supplier
supplier
)

Returns a ExceptionSupplier with identical behavior to the specified ExceptionSupplier but with relaxed return type and relaxed exception type.

public static <
the parameter type
T
,
the return type
R extends RR
,
the exception type
E extends EE
,
the restricted parameter type
TT extends T
,
the relaxed return type
RR
,
the relaxed exception type
EE extends Exception
>
ExceptionFunction<TT, RR, EE>

Returns:

a functionally equivalent function
cast
(ExceptionFunction<T, R, E>
a function
function
)

Returns a ExceptionFunction with identical behavior to the specified ExceptionFunction but with restricted parameter type, relaxed return type, and relaxed exception type.

public static <
the return type
R extends RR
,
the exception type
E extends EE
,
the relaxed return type
RR
,
the relaxed exception type
EE extends Exception
>
ExceptionIntFunction<RR, EE>

Returns:

a functionally equivalent function
cast
(ExceptionIntFunction<R, E>
a function
function
)

Returns a ExceptionIntFunction with identical behavior to the specified ExceptionFunction but with relaxed return type and relaxed exception type.

public static <
the return type
R extends RR
,
the exception type
E extends EE
,
the relaxed return type
RR
,
the relaxed exception type
EE extends Exception
>
ExceptionLongFunction<RR, EE>

Returns:

a functionally equivalent function
cast
(ExceptionLongFunction<R, E>
a function
function
)

Returns a ExceptionLongFunction with identical behavior to the specified ExceptionLongFunction but with relaxed return type and relaxed exception type.

public static <
the parameter type
T
,
the exception type
E extends EE
,
the restricted parameter type
TT extends T
,
the relaxed exception type
EE extends Exception
>
ExceptionToIntFunction<TT, EE>

Returns:

a functionally equivalent function
cast
(ExceptionToIntFunction<T, E>
a function
function
)

Returns a ExceptionToIntFunction with identical behavior to the specified ExceptionToIntFunction but with restricted parameter type and relaxed exception type.

public static <
the parameter type
T
,
the exception type
E extends EE
,
the restricted parameter type
TT extends T
,
the relaxed exception type
EE extends Exception
>
ExceptionToLongFunction<TT, EE>

Returns:

a functionally equivalent function
cast
(ExceptionToLongFunction<T, E>
a function
function
)

Returns a ExceptionToLongFunction with identical behavior to the specified ExceptionToLongFunction but with restricted parameter type and relaxed exception type.

public static <
the first parameter type
T
,
the exception type
E extends EE
,
the restricted first parameter type
TT extends T
,
the second parameter type
U
,
the restricted second parameter type
UU extends U
,
the relaxed exception type
EE extends Exception
>
ExceptionBiConsumer<TT, UU, EE>

Returns:

a functionally equivalent consumer
cast
(ExceptionBiConsumer<T, U, E>
a consumer
consumer
)

Returns a ExceptionBiConsumer with identical behavior to the specified ExceptionBiConsumer but with restricted parameter types and relaxed exception type.

public static <
the parameter type
T
,
the exception type
E extends EE
,
the restricted parameter type
TT extends T
,
the relaxed exception type
EE extends Exception
>
ExceptionObjIntConsumer<TT, EE>

Returns:

a functionally equivalent consumer
cast
(ExceptionObjIntConsumer<T, E>
a consumer
consumer
)

Returns a ExceptionObjIntConsumer with identical behavior to the specified ExceptionObjIntConsumer but with restricted parameter type and relaxed exception type.

public static <
the parameter type
T
,
the exception type
E extends EE
,
the restricted parameter type
TT extends T
,
the relaxed exception type
EE extends Exception
>
ExceptionObjLongConsumer<TT, EE>

Returns:

a functionally equivalent consumer
cast
(ExceptionObjLongConsumer<T, E>
a consumer
consumer
)

Returns a ExceptionObjLongConsumer with identical behavior to the specified ExceptionObjLongConsumer but with restricted parameter type and relaxed exception type.

public static <
the first parameter type
T
,
the second parameter type
U
,
the exception type
E extends EE
,
the restricted first parameter type
TT extends T
,
the restricted second parameter type
UU extends U
,
the relaxed exception type
EE extends Exception
>
ExceptionBiPredicate<TT, UU, EE>

Returns:

a functionally equivalent predicate
cast
(ExceptionBiPredicate<T, U, E>
a predicate
predicate
)

Returns a ExceptionBiPredicate with identical behavior to the specified ExceptionBiPredicate but with restricted parameter types and relaxed exception type.

public static <
the first parameter type
T
,
the second parameter type
U
,
the return type
R extends RR
,
the exception type
E extends EE
,
the restricted first parameter type
TT extends T
,
the restricted second parameter type
UU extends U
,
the relaxed return type
RR
,
the relaxed exception type
EE extends Exception
>
ExceptionBiFunction<TT, UU, RR, EE>

Returns:

a functionally equivalent function
cast
(ExceptionBiFunction<T, U, R, E>
a function
function
)

Returns a ExceptionBiFunction with identical behavior to the specified ExceptionBiFunction but with restricted parameter types, relaxed return type, and relaxed exception type.

public static <
the first parameter type
T
,
the second parameter type
U
,
the exception type
E extends EE
,
the restricted first parameter type
TT extends T
,
the restricted second parameter type
UU extends U
,
the relaxed exception type
EE extends Exception
>
ExceptionToIntBiFunction<TT, UU, EE>

Returns:

a functionally equivalent function
cast
(ExceptionToIntBiFunction<T, U, E>
a function
function
)

Returns a ExceptionToIntBiFunction with identical behavior to the specified ExceptionToIntBiFunction but with restricted parameter types and relaxed exception type.

public static <
the first parameter type
T
,
the second parameter type
U
,
the exception type
E extends EE
,
the restricted first parameter type
TT extends T
,
the restricted second parameter type
UU extends U
,
the relaxed exception type
EE extends Exception
>
ExceptionToLongBiFunction<TT, UU, EE>

Returns:

a functionally equivalent function
cast
(ExceptionToLongBiFunction<T, U, E>
a function
function
)

Returns a ExceptionToLongBiFunction with identical behavior to the specified ExceptionToLongBiFunction but with restricted parameter types and relaxed exception type.

public static <
the closeable type
T extends AutoCloseable
>
Consumer<T>

Returns:

a closing consumer
closingConsumer
()

Returns a consumer that quietly closes its argument, logging any exceptions.

public static <
the value type
T
,
the exception type
E extends Exception
>
ExceptionSupplier<T, E>

Returns:

the value supplier
constantExceptionSupplier
(T
the value to return
value
)

Get a supplier which always returns the same value.

public static <
the value type
T
>
Supplier<T>

Returns:

the value supplier
constantSupplier
(T
the value to return
value
)

Get a supplier which always returns the same value.

public static <
the argument type
T
>
BiConsumer<Consumer<T>, T>

Returns:

the consumer
consumerBiConsumer
()

Get the singleton consumer which accepts a consumer and an argument to hand to it.

public static <
the argument type
T
>
ExceptionBiConsumer<Consumer<T>, T, RuntimeException>

Returns:

the consumer
consumerExceptionBiConsumer
()

Get the singleton consumer which accepts a consumer and an argument to hand to it.

public static <
the first parameter type
T
,
the second parameter type
U
>
BiConsumer<T, U>

Returns:

the discarding consumer
discardingBiConsumer
()

Get a consumer which discards the values it is given.

public static <
the parameter type
T
>
Consumer<T>

Returns:

the discarding consumer
discardingConsumer
()

Get a consumer which discards the values it is given.

public static <
the first parameter type
T
,
the second parameter type
U
,
the exception type
E extends Exception
>
ExceptionBiConsumer<T, U, E>

Returns:

the discarding consumer
discardingExceptionBiConsumer
()

Get a consumer which discards the values it is given.

public static <
the parameter type
T
,
the exception type
E extends Exception
>
ExceptionConsumer<T, E>

Returns:

the discarding consumer
discardingExceptionConsumer
()

Get a consumer which discards the values it is given.

public static <
the first parameter type
T
,
the second parameter type
U
,
the exception type
E extends Exception
>
ExceptionRunnable<E>

Returns:

the capturing runnable
exceptionCapturingRunnable
(ExceptionBiConsumer<T, U, E>
the consumer to run (must not be null)
consumer
,
T
the first parameter to pass
param1
,
U
the second parameter to pass
param2
)

Get a runnable which executes the given consumer with captured values.

public static <
the parameter type
T
,
the exception type
E extends Exception
>
ExceptionRunnable<E>

Returns:

the capturing runnable
exceptionCapturingRunnable
(ExceptionConsumer<T, E>
the consumer to run (must not be null)
consumer
,
T
the parameter to pass
param
)

Get a runnable which executes the given consumer with captured values.

public static <
the argument type
T
,
the exception type
E extends Exception
>
ExceptionBiConsumer<ExceptionConsumer<T, E>, T, E>

Returns:

the consumer
exceptionConsumerBiConsumer
()

Get the singleton consumer which accepts a consumer and an argument to hand to it.

public static <
the argument type
T
,
the result type
R
,
the exception type
E extends Exception
>
ExceptionBiFunction<ExceptionFunction<T, R, E>, T, R, E>

Returns:

the function
exceptionFunctionBiFunction
()

Get the singleton function which accepts a function and a parameter to pass to the function, and returns the result of the function.

public static <
the exception type
E extends Exception
>
Consumer<E>

Returns:

an exception consumer
exceptionLoggingConsumer
()

Returns a consumer that logs its exception parameter as a warning.

public static <
the exception type
E extends Exception
>
ExceptionConsumer<ExceptionRunnable<E>, E>

Returns:

the runnable consumer
exceptionRunnableConsumer
()

Get the singleton exception consumer which accepts and runs exception runnable instances.

public static <
the result type
R
,
the exception type
E extends Exception
>
ExceptionFunction<ExceptionSupplier<R, E>, R, E>

Returns:

the function
exceptionSupplierFunction
()

Get the singleton function which accepts a supplier and returns the result of the supplier.

public static <
the result type
R
,
the exception type
E extends Exception
>
ExceptionBiFunction<ExceptionFunction<ExceptionSupplier<R, E>, R, E>, ExceptionSupplier<R, E>, R, E>

Returns:

the function
exceptionSupplierFunctionBiFunction
()

Get the singleton function which accepts a function which accepts a supplier, all of which return the result of the supplier.

public static <
the argument type
T
,
the result type
R
>
BiFunction<Function<T, R>, T, R>

Returns:

the function
functionBiFunction
()

Get the singleton function which accepts a function and a parameter to pass to the function, and returns the result of the function.

public static <
the argument type
T
,
the result type
R
>
ExceptionBiFunction<Function<T, R>, T, R, RuntimeException>

Returns:

the function
functionExceptionBiFunction
()

Get the singleton function which accepts a function and a parameter to pass to the function, and returns the result of the function.

public static <
the parameter type of the consumer
T
,
the exception type
E extends Exception
>
Consumer<T>

Returns:

a standard consumer
quiet
(ExceptionConsumer<T, E>
an exception consumer
consumer
,
Consumer<E>
an exception handler
handler
)

Converts an ExceptionConsumer to a standard Consumer using the specified exception handler.

public static <
the first parameter type of the consumer
T
,
the second parameter type of the consumer
U
,
the exception type
E extends Exception
>
BiConsumer<T, U>

Returns:

a standard binary consumer
quiet
(ExceptionBiConsumer<T, U, E>
a binary exception consumer
consumer
,
Consumer<E>
an exception handler
handler
)

Converts an ExceptionBiConsumer to a standard BiConsumer using the specified exception handler.

public static <
the first parameter type of the consumer
T
,
the exception type
E extends Exception
>
ObjIntConsumer<T>

Returns:

a standard object/int consumer
quiet
(ExceptionObjIntConsumer<T, E>
an object/int exception consumer
consumer
,
Consumer<E>
an exception handler
handler
)

Converts an ExceptionObjIntConsumer to a standard ObjIntConsumer using the specified exception handler.

public static <
the first parameter type of the consumer
T
,
the exception type
E extends Exception
>
ObjLongConsumer<T>

Returns:

a standard object/long consumer
quiet
(ExceptionObjLongConsumer<T, E>
an object/long exception consumer
consumer
,
Consumer<E>
an exception handler
handler
)

Converts an ExceptionObjLongConsumer to a standard ObjLongConsumer using the specified exception handler.

public static Consumer<Runnable>

Returns:

the runnable consumer
runnableConsumer
()

Get the singleton consumer which accepts and runs runnable instances.

public static ExceptionConsumer<Runnable, RuntimeException>

Returns:

the runnable consumer
runnableExceptionConsumer
()

Get the singleton exception consumer which accepts and runs runnable instances.

public static <
the exception type
E extends Exception
,
the runtime exception type
RE extends RuntimeException
>
Consumer<E>

Returns:

an exception consumer
runtimeExceptionThrowingConsumer
(Function<E, RE>
a runtime exception wrapper
wrapper
)

Returns a consumer that wraps and throws its exception parameter as a RuntimeException.

public static <
the result type
R
>
ExceptionFunction<Supplier<R>, R, RuntimeException>

Returns:

the function
supplierExceptionFunction
()

Get the singleton function which accepts a supplier and returns the result of the supplier.

public static <
the result type
R
>
Function<Supplier<R>, R>

Returns:

the function
supplierFunction
()

Get the singleton function which accepts a supplier and returns the result of the supplier.

public static <
the result type
R
>
BiFunction<Function<Supplier<R>, R>, Supplier<R>, R>

Returns:

the function
supplierFunctionBiFunction
()

Get the singleton function which accepts a function which accepts a supplier, all of which return the result of the supplier.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait