Package xyz.brandonfl.throwableoptional
Class ThrowableOptional
- java.lang.Object
-
- xyz.brandonfl.throwableoptional.ThrowableOptional
-
public final class ThrowableOptional extends java.lang.Object
ThrowableOptional is a utility class that enables the possibility to use the Optional with functions that can throw exceptions- Author:
- brandonfl
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.util.Optional<T>
of(java.util.concurrent.Callable<T> function)
ThrowableOptional of callable functions Exemple :ThrowableOptional.of(() -> Long.parseLong(value))
static <T,R>
java.util.Optional<R>of(java.util.function.Function<T,R> function, T parameter)
ThrowableOptional of functions with one parameter Exemple :ThrowableOptional.of(Long::parseLong, value)
-
-
-
Method Detail
-
of
public static <T> java.util.Optional<T> of(java.util.concurrent.Callable<T> function)
ThrowableOptional of callable functions Exemple :ThrowableOptional.of(() -> Long.parseLong(value))
- Type Parameters:
T
- Type of the parameter- Parameters:
function
- a callable function- Returns:
- Optional of the throwable function
-
of
public static <T,R> java.util.Optional<R> of(java.util.function.Function<T,R> function, T parameter)
ThrowableOptional of functions with one parameter Exemple :ThrowableOptional.of(Long::parseLong, value)
- Type Parameters:
T
- Type of the parameterR
- Result of the function- Parameters:
function
- the function callparameter
- the parameter for the function- Returns:
- Optional of the throwable function
-
-