接口 ThrowableFunction<T,​R>

  • 类型参数:
    T - the source type
    R - the return type
    函数接口:
    这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。

    @FunctionalInterface
    public interface ThrowableFunction<T,​R>
    Function with Throwable
    从以下版本开始:
    1.0.0
    另请参阅:
    Function, Throwable
    • 方法概要

      所有方法 静态方法 实例方法 抽象方法 默认方法 
      修饰符和类型 方法 说明
      default <V> ThrowableFunction<T,​V> andThen​(ThrowableFunction<? super R,​? extends V> after)
      Returns a composed throwable-function that first applies this throwable-function to its input, and then applies the after throwable-function to the result.
      R apply​(T t)
      Applies this function to the given argument.
      default <V> ThrowableFunction<V,​R> compose​(ThrowableFunction<? super V,​? extends T> before)
      Returns a composed throwable-function that first applies the before throwable-function to its input, and then applies this throwable-function to the result.
      default R execute​(T t)
      Executes #apply(T) with the default exception handling
      static <T,​R>
      R
      execute​(T t, ThrowableFunction<T,​R> function)
      Executes ThrowableFunction with the default exception handling
      static <T,​R>
      R
      execute​(T t, ThrowableFunction<T,​R> function, java.util.function.BiFunction<T,​java.lang.Throwable,​R> exceptionHandler)
      Executes ThrowableFunction with the customized exception handling
      default R execute​(T t, java.util.function.BiFunction<T,​java.lang.Throwable,​R> exceptionHandler)
      Executes #apply(T) with the customized exception handling
      default R handleException​(T t, java.lang.Throwable failure)
      Handle any exception that the #apply(T) method throws
    • 方法详细资料

      • apply

        R apply​(T t)
         throws java.lang.Throwable
        Applies this function to the given argument.
        参数:
        t - the function argument
        返回:
        the function result
        抛出:
        java.lang.Throwable - if met with any error
      • execute

        default R execute​(T t)
                   throws java.lang.RuntimeException
        Executes #apply(T) with the default exception handling
        参数:
        t - the function argument
        返回:
        the function result
        抛出:
        java.lang.RuntimeException
      • execute

        default R execute​(T t,
                          java.util.function.BiFunction<T,​java.lang.Throwable,​R> exceptionHandler)
                   throws java.lang.RuntimeException
        Executes #apply(T) with the customized exception handling
        参数:
        t - the function argument
        exceptionHandler - the handler to handle the function argument and the exception that the #apply(T) method throws
        返回:
        the function result
        抛出:
        java.lang.RuntimeException
      • handleException

        default R handleException​(T t,
                                  java.lang.Throwable failure)
        Handle any exception that the #apply(T) method throws
        参数:
        t - the value to be consumed
        failure - the instance of Throwable
      • compose

        default <V> ThrowableFunction<V,​R> compose​(ThrowableFunction<? super V,​? extends T> before)
        Returns a composed throwable-function that first applies the before throwable-function to its input, and then applies this throwable-function to the result. If evaluation of either throwable-function throws an exception, it is relayed to the caller of the composed throwable-function.
        类型参数:
        V - the type of input to the before throwable-function, and to the composed throwable-function
        参数:
        before - the throwable-function to apply before this throwable-function is applied
        返回:
        a composed throwable-function that first applies the before throwable-function and then applies this throwable-function
        抛出:
        java.lang.NullPointerException - if before is null
        另请参阅:
        andThen(ThrowableFunction)
      • andThen

        default <V> ThrowableFunction<T,​V> andThen​(ThrowableFunction<? super R,​? extends V> after)
        Returns a composed throwable-function that first applies this throwable-function to its input, and then applies the after throwable-function to the result. If evaluation of either throwable-function throws an exception, it is relayed to the caller of the composed throwable-function.
        类型参数:
        V - the type of output of the after throwable-function, and of the composed throwable-function
        参数:
        after - the throwable-function to apply after this throwable-function is applied
        返回:
        a composed throwable-function that first applies this throwable-function and then applies the after throwable-function
        抛出:
        java.lang.NullPointerException - if after is null
        另请参阅:
        compose(ThrowableFunction)
      • execute

        static <T,​R> R execute​(T t,
                                     ThrowableFunction<T,​R> function)
                              throws java.lang.NullPointerException
        Executes ThrowableFunction with the default exception handling
        类型参数:
        T - the source type
        R - the return type
        参数:
        t - the throwable-function argument
        function - ThrowableFunction
        返回:
        the result after execution
        抛出:
        java.lang.NullPointerException - if function is null
      • execute

        static <T,​R> R execute​(T t,
                                     ThrowableFunction<T,​R> function,
                                     java.util.function.BiFunction<T,​java.lang.Throwable,​R> exceptionHandler)
                              throws java.lang.NullPointerException
        Executes ThrowableFunction with the customized exception handling
        类型参数:
        T - the source type
        R - the return type
        参数:
        t - the function argument
        exceptionHandler - the handler to handle the function argument and the exception that the #apply(T) method throws
        function - ThrowableFunction
        返回:
        the result after execution
        抛出:
        java.lang.NullPointerException - if function and exceptionHandler is null