Class 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)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 parameter
        R - Result of the function
        Parameters:
        function - the function call
        parameter - the parameter for the function
        Returns:
        Optional of the throwable function