public class FunctionalUtils extends Object
| Constructor and Description |
|---|
FunctionalUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
ifPresent(Optional<T> optional,
Consumer<? super T> ifPresent,
Runnable orElse)
If the
optional is present, it executes the ifPresent consumer. |
static <T> Optional<T> |
or(Optional<T> optional,
Supplier<Optional<T>> orElse)
If the given
optional is not present, then it returns the optional
provided by the orElse supplier |
static void |
safely(CheckedRunnable task)
Executes the given task, ignoring thrown exceptions.
|
static void |
safely(CheckedRunnable task,
Consumer<Exception> exceptionHandler)
Executes the given
task, feeding any thrown exceptions into the given
exceptionHandler |
public static void safely(CheckedRunnable task)
task - the task to executepublic static void safely(CheckedRunnable task, Consumer<Exception> exceptionHandler)
task, feeding any thrown exceptions into the given
exceptionHandlertask - a taskexceptionHandler - an exception Consumerpublic static <T> Optional<T> or(Optional<T> optional, Supplier<Optional<T>> orElse)
optional is not present, then it returns the optional
provided by the orElse supplierpublic static <T> void ifPresent(Optional<T> optional, Consumer<? super T> ifPresent, Runnable orElse)
optional is present, it executes the ifPresent consumer. Otherwise,
it executes the orElse runnableT - the generic type of the optional's value.optional - an Optional valueifPresent - the consumer to execute if the value is presentorElse - a fallback runnable in case the optional is empty.Copyright © 2003–2017 MuleSoft, Inc.. All rights reserved.