Module bus.core

Interface FunctionX<T,R>

Type Parameters:
T - 参数类型
R - 返回值类型
All Superinterfaces:
Function<T,R>, Serializable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface FunctionX<T,R> extends Function<T,R>, Serializable
可序列化的Function接口,支持异常抛出。
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default R
    apply(T t)
    对给定参数应用此函数,自动处理异常。
    对给定参数应用此函数,可能抛出异常。
    static <T, R> Function<T,R>
    返回一个支持类型转换的恒等函数。
    static <T> FunctionX<T,T>
    返回一个始终返回输入参数的函数。

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Method Details

    • identity

      static <T> FunctionX<T,T> identity()
      返回一个始终返回输入参数的函数。
      Type Parameters:
      T - 函数输入和输出的类型
      Returns:
      始终返回输入参数的函数
    • castingIdentity

      static <T, R> Function<T,R> castingIdentity()
      返回一个支持类型转换的恒等函数。
      Type Parameters:
      T - 输入参数类型
      R - 返回值类型
      Returns:
      类型转换后的恒等函数
    • applying

      R applying(T t) throws Throwable
      对给定参数应用此函数,可能抛出异常。
      Parameters:
      t - 函数输入参数
      Returns:
      函数执行结果
      Throws:
      Throwable - 可能抛出的异常
    • apply

      default R apply(T t)
      对给定参数应用此函数,自动处理异常。
      Specified by:
      apply in interface Function<T,R>
      Parameters:
      t - 函数输入参数
      Returns:
      函数执行结果
      Throws:
      RuntimeException - 包装后的运行时异常