接口 ThrowableSupplier<T>

  • 函数接口:
    这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。

    @FunctionalInterface
    public interface ThrowableSupplier<T>
    • 方法详细资料

      • get

        T get()
        throws java.lang.Throwable
        Applies this function to the given argument.
        返回:
        the supplied result
        抛出:
        java.lang.Throwable - if met with any error
      • execute

        default T execute​(java.util.function.Function<java.lang.Throwable,​T> exceptionHandler)
        Execute get() with the customized exception handling
        参数:
        exceptionHandler - the handler to handle any exception that the get() method throws
        返回:
        the supplied result
        另请参阅:
        execute()
      • handleException

        default T handleException​(java.lang.Throwable failure)
        Handle any exception that the get() method throws
        参数:
        failure - the instance of Throwable
        返回:
        the result after the exception handling
      • execute

        static <T> T execute​(ThrowableSupplier<T> supplier,
                             java.util.function.Function<java.lang.Throwable,​T> exceptionHandler)
                      throws java.lang.NullPointerException
        Executes ThrowableSupplier with the customized exception handling
        类型参数:
        T - the supplied type
        参数:
        supplier - ThrowableSupplier
        exceptionHandler - the handler to handle any exception that the get() method throws
        返回:
        the result after execution
        抛出:
        java.lang.NullPointerException - if supplier or exceptionHandler is null