Package io.openems.common.utils
Class FunctionUtils
java.lang.Object
io.openems.common.utils.FunctionUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Helper method to create emptyRunnable
orThrowingRunnable
.static <T> void
doNothing
(T t) Helper method to create emptyConsumer
orThrowingConsumer
.static <T,
U> void doNothing
(T t, U e) Helper method to create emptyBiConsumer
orThrowingBiConsumer
.static <T> Supplier
<T> Helper method to create aSupplier
.
-
Method Details
-
doNothing
public static void doNothing()Helper method to create emptyRunnable
orThrowingRunnable
.Usage:
final Runnable runnable = FunctionUtils::doNothing; final ThrowingRunnable<Exception> runnable = FunctionUtils::doNothing;
-
doNothing
public static <T> void doNothing(T t) Helper method to create emptyConsumer
orThrowingConsumer
.Usage:
final Consumer<String> consumer = FunctionUtils::doNothing; final ThrowingConsumer<String, Exception> consumer = FunctionUtils::doNothing;
- Type Parameters:
T
- the type of the first input parameter- Parameters:
t
- the first input parameter
-
doNothing
public static <T,U> void doNothing(T t, U e) Helper method to create emptyBiConsumer
orThrowingBiConsumer
.Usage:
final BiConsumer<String> consumer = FunctionUtils::doNothing; final ThrowingBiConsumer<String, Exception> consumer = FunctionUtils::doNothing;
- Type Parameters:
T
- the type of the first input parameterU
- the type of the second input parameter- Parameters:
t
- the first input parametere
- the second input parameter
-
supplier
Helper method to create aSupplier
.Instead of an explicit type:
final Supplier<String> provideString = () -> { return ""; };
... an implicit type based on the return value can be used:
final var provideString = supplier(() -> { return ""; });
-