Class Try


  • public final class Try
    extends Object
    Utility class for try/catch handling
    Author:
    Brian Wyka
    • Method Detail

      • attemptOrDefault

        public static <T> T attemptOrDefault​(Try.CheckedSupplier<T> supplier,
                                             Function<Throwable,​T> defaultFunction)
        Surround the Try.CheckedSupplier with a try/catch
        Type Parameters:
        T - the type of the return value
        Parameters:
        supplier - the supplier of the return value
        defaultFunction - the default value function if an exception is thrown
        Returns:
        the result of the supplier if successful, otherwise the result of the default function