Package org.apache.flink.util
Class OptionalConsumer<T>
- java.lang.Object
-
- org.apache.flink.util.OptionalConsumer<T>
-
- Type Parameters:
T
- type of the optional
public class OptionalConsumer<T> extends Object
Utility class which allows to run code depending on whether the optional has a value or is empty.This code has been copied from: https://stackoverflow.com/a/29395324/4815083.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <E extends Exception>
OptionalConsumer<T>ifNotPresent(ThrowingRunnable<E> r)
OptionalConsumer<T>
ifPresent(Consumer<T> c)
static <T> OptionalConsumer<T>
of(Optional<T> optional)
-
-
-
Method Detail
-
of
public static <T> OptionalConsumer<T> of(Optional<T> optional)
-
ifPresent
public OptionalConsumer<T> ifPresent(Consumer<T> c)
-
ifNotPresent
public <E extends Exception> OptionalConsumer<T> ifNotPresent(ThrowingRunnable<E> r) throws E extends Exception
- Throws:
E extends Exception
-
-